<html>
<head>
  <title>Evernote Export</title>
  <basefont face="微软雅黑" size="2" />
  <meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
  <meta name="exporter-version" content="YXBJ Windows/604762 (zh-CN, DDL); Windows/10.0.0 (Win64); EDAMVersion=V2;"/>
  <style>
    body, td {
      font-family: 微软雅黑;
      font-size: 10pt;
    }
  </style>
</head>
<body>
<a name="506"/>

<div>
<span><div><span style="font-size: 16pt; font-family: Eurostile;">异步编程</span> <span style="font-size: 16pt; font-family: Eurostile;"><a href="https://zhuanlan.zhihu.com/p/310646064">c#异步编程-Task（一） - 知乎 (zhihu.com)</a></span></div><div><span style="font-size: 16pt; font-family: Eurostile;">    1.Thread(线程)</span></div><div><span style="font-size: 16pt; font-family: Eurostile;">被抢占【术语】：一个线程和另一个线程运行的交织点</span></div><div><span style="font-size: 16pt; font-family: Eurostile;"> 【重要属性】</span></div><div><span style="font-size: 16pt; font-family: Eurostile;">    线程一旦执行，isAlive = true; 线程结束 </span><span style="font-size: 16pt; font-family: Eurostile;">isAlive = false;</span></div><div><span style="font-size: 16pt; font-family: Eurostile;">    传入线程的委托一旦结束该线程就结束了，线程一旦结束就无法再重启；线程名不可以重复修改</span></div><div><span style="font-size: 16pt; font-family: Eurostile;">    1.Join 和 Sleep</span></div><div><span style="font-size: 16pt; font-family: Eurostile;">    join:使用join方法就会等待这个线程结束，再执行别的线程的内容。可以设置join的限制时间毫秒或者timeSpan;返回true说明做完，如果超时则返回false</span></div><div><span style="font-size: 16pt; font-family: Eurostile;">    Sleep:会暂停当前的线程，并等待一段时间。如果传值为0这样会导致该线程立即放弃当前的时间篇，自动将cpu移交给其他线程</span><span style="font-size: 16pt; font-family: Eurostile;">    #Yield也是做相同的事情，但是他是把执行交给同一处理器上的其他线程</span></div><div><span style="font-size: 16pt; font-family: Eurostile;">    2.blocking阻塞</span></div><div><span style="font-size: 16pt; font-family: Eurostile;">    定义：如果线程因为某种原因暂定，那么可以认为i该线程被阻塞了（比如在sleep或者其他线程的被join操作），这时被阻塞的线程会将其处理器的时间片交给其他线程，直到满足恢复条件为止。可以通过ThreadState来判断是否处于阻塞。</span></div><div><span style="font-size: 16pt; font-family: Eurostile;">    线程状态：（flag enum）</span></div><div><span style="font-size: 16pt; font-family: Eurostile;"><img src="Evernote_files/Image.png" type="image/png" data-filename="Image.png" width="651"/></span></div><div><span style="font-size: 16pt; font-family: Eurostile;">    解除阻塞：</span></div><div><span style="font-size: 16pt; font-family: Eurostile;">        当阻塞条件被满足；操作超时；通过Interrupt打断；通过abort中止</span></div><div><span style="font-size: 16pt; font-family: Eurostile;">   上下文切换：当线程阻塞或者解除阻塞，操作系统将执行上下文切换，会产生1或2微秒的开销 </span></div><div><span style="font-size: 16pt; font-family: Eurostile;">阻塞Vs忙等待（spinning）</span></div><div><span style="font-size: 16pt; font-family: Eurostile;">IO_bound:一个花费大部分时间等待某件事发生的操作;常见的有输入和输出，<span style="font-size: 16pt; font-family: Eurostile; font-weight: bold;">Sleep操作</span></span></div><div><span style="font-size: 16pt; font-family: Eurostile;">    工作方式：在当前线程上同步的等待，这种操作是将大部分时间花费在阻塞线程上，他们可以周期性的在一个循环里进行“自旋（忙等待）”如：console.readLine(),Thread.sleep(),Thread.Join();</span></div><div><span style="font-size: 16pt; font-family: Eurostile;">                        异步操作，在稍后操作完成时触发一个回调动作</span></div><div><span style="font-size: 16pt;"><br/></span></div><div><span style="font-size: 16pt; font-family: Eurostile;">CPU_bound:</span><span style="font-size: 16pt; font-family: Eurostile;">一个花费大部分时间执行cpu密集型工作的操作</span></div><div><span style="font-size: 16pt; font-family: Eurostile;">3.线程安全问题</span></div><div><span style="font-size: 16pt; font-family: Eurostile;">    本地和共享状态</span></div><div><span style="font-size: 16pt; font-family: Eurostile;">    本地：CLR会为每个线程分配自己的内存栈，以便本地变量保持独立，如方法里的变量</span></div><div><span style="font-size: 16pt; font-family: Eurostile;">    共享：如果多个线程都引用到同一个对象的实例，这就是共享。<span style="font-size: 16pt; font-family: Eurostile; text-decoration: underline;">被Lambda表达式或者匿名委托捕获的本地变量会被编译器转化为字段，所以会被共享。静态字段也会被共享。</span></span></div><div><span style="font-size: 16pt; font-family: Eurostile;">解决共享状态：在读取和写入共享数据时通过一个互斥锁 </span></div><div><span style="font-size: 16pt; font-family: Eurostile;">    需要注意的是在try/catch的作用域里开辟线程，执行是不会捕获其异常的</span></div><div><span style="font-size: 16pt; font-family: Eurostile;">4.前后台线程</span></div><div><span style="font-size: 16pt; font-family: Eurostile;">    只要存在前台线程应用就是处于活动状态（默认手动创建的线程都是前台），一旦所有前台线程停止这个程序就停止了，程序停止后台线程自动结束。后台进程以这种形式终止时，该执行栈中的finally块就不会执行</span></div><div><span style="font-size: 16pt; font-family: Eurostile;">    可以通过isBackground字段判断线程属于前后台</span></div><div><span style="font-size: 16pt; font-family: Eurostile;">5.线程优先级</span></div><div><span style="font-size: 16pt; font-family: Eurostile;">    Priority决定了相对于操作系统中其他活跃线程所占用的时间；分为5种{Lowest,BelowNormal,Normal,AboveNormal,highest}</span></div><div><span style="font-size: 16pt; font-family: Eurostile;">6.信号：有时需要让某一线程处于等待状态，直到接收到其他线程发来的通知。最简单的信号结构就是ManualResetEvent:在A线程调用WaitOne方法就会阻塞，直到B线程通过Set方法来开启信号</span></div><div><span style="font-size: 16pt; font-family: Eurostile;">7.线程池</span></div><div><span style="font-size: 16pt; font-family: Eurostile;">    注意：不可以设置池线程name;池线程都是后台线程；阻塞池线程会导致性能降级</span></div><div><span style="font-size: 16pt; font-family: Eurostile;">    但是可以自由更改池线程的优先级，当它回收是又会变为正常状态。可以通过Thread.CurrentThread.IsThreadPoolThread的属性判断是否执行在池线程上。</span></div><div><span style="font-size: 16pt; font-family: Eurostile;">线程池会确保超出CPU_bound的工作不会导致Cpu超额订阅（活跃的线程超过CPU的核数，操作系统就需要对线程进行时间切片，这个对性能影响很大）</span></div><div><span style="font-size: 16pt; font-family: Eurostile;">CLR对线程池的策略:爬山算法,如果吞吐量提高就会朝同一方向调整.满足以下两点可使这个策略发挥更好的效果:</span></div><div><span style="font-size: 16pt; font-family: Eurostile;"><span>    1.工作项为250ms以下的2.大部分时间都被阻塞的工作项不会主宰线程池</span><br/></span></div><div><span style="font-size: 16pt; font-family: Eurostile;"><br/></span></div><div><span style="font-size: 16pt; font-family: Eurostile;">8.Task——适合短时间的Cpu_bound类工作</span></div><div><span style="font-size: 16pt; font-family: Eurostile;">    默认使用线程池，即后台线程，使用</span><span style="min-height: 11pt;"><span style="font-size: 16pt; font-family: Eurostile;">RunSynchronously（）可以</span></span></div><div><span style="font-size: 16pt; font-family: Eurostile;">    启动：（</span><span style="font-size: 16pt; font-family: Eurostile;">热启动直接执行</span><span style="font-size: 16pt; font-family: Eurostile;">）1.Task.Run2.</span><span style="min-height: 11pt;"><span style="font-size: 16pt; font-family: Eurostile;">Task.Factory.StartNew （需要额外调用）3.构造一个Task</span></span></div><div><span style="min-height: 11pt;"><span style="font-size: 16pt; font-family: Eurostile;">    调用Wait方法可以进行阻塞直到操作完成，相当于调用线程中的join. 也可以使用超时令牌和指定时间来控制等待时间。</span></span></div><div><span style="min-height: 11pt;"><span style="font-size: 16pt; font-family: Eurostile;">Task有个泛型的子类允许发出一个返回值，通过Result这个属性获取结果，但是访问这个属性会阻塞该线程。</span></span></div><div><span style="min-height: 11pt;"><span style="font-size: 16pt; font-family: Eurostile;">对Task使用getAwaiter()就会返回一个awaiter对象.awaiter定义:拥有Oncompleted委托,isCompleted属性和GetResult方法的对象就可以视为awaiter   </span></span></div><div><span style="min-height: 11pt;"><span style="font-size: 16pt; font-family: Eurostile;">continuWith注册task完成的回调</span></span></div><div><span style="min-height: 11pt;"><span style="font-size: 16pt; font-family: Eurostile; font-weight: bold;">TaskCompletionSource</span><span style="font-size: 16pt; font-family: Eurostile;">可以在稍后开始和结束的任意操作中创建Task,提供一个可手动执行的</span><span style="font-size: 16pt; font-family: Eurostile; text-decoration: underline;">从属Task</span><span style="font-size: 16pt; font-family: Eurostile;">对于Io_bound的工作是比较理想的选择，不会阻塞线程;</span></span><span style="color: unset; font-family: Eurostile; font-size: 16pt;">拥有一个Task的属性，这个Task完全由该类控制，调用任意一个方法都会给Task发信号：完成，故障，取消；这些方法只用调用一次，如果再次调用setxxx()会抛异常，Tryxxx会返回false.</span></div><div><font style="font-size: 16pt;"><span style="font-size: 16pt; font-family: Eurostile; font-weight: bold;">TaskCompletionSource创建的Task不占用线程</span></font></div><div><font style="font-size: 16pt;"><span style="font-size: 16pt; font-family: Eurostile; font-weight: bold;">9.同步与异步 </span></font></div><div><span style="font-size: 16pt; font-family: Eurostile; font-weight: bold;"> </span><span style="font-size: 16pt; font-family: Eurostile;">   同步：同步操作会在返回调用者之前完成其工作</span></div><div><span style="font-size: 16pt; font-family: Eurostile;">    异步：会在返回调用者之后去做工作，异步方法会启用并发，因为他的工作会与调用者并行执行，非阻塞方法</span></div><div><span style="font-size: 16pt; font-family: Eurostile;">异步编程的原则是将长时间运行的函数写成异步的，传统做法则是将长时间运行的函数写成同步，之后从新的线程或者Task进行调用，从而按需并发。</span></div><div><span style="font-size: 16pt; font-family: Eurostile;">    异步编程好处：IO_bound并发可以不使用线程实现，提高可扩展性和执行效率</span></div><div><span style="font-size: 16pt; font-family: Eurostile;">凡是返回 Task 的方法 前边都可以用await</span></div><div><span style="font-size: 16pt; font-family: Eurostile;">Await关键字简化了附加continuation的过程。</span><span style="font-size: 16pt; font-family: Eurostile;"><img src="Evernote_files/Image [1].png" type="image/png" data-filename="Image.png" width="750"/></span></div><div><span style="font-size: 16pt; font-family: Eurostile;">Async修饰符会让编译器把await当作关键字，只能用于方法和lambda表达式，该方法可以返回void task,task&lt;t&gt;;async对方法的签名或pulic与数据没有影响，只会影响方法内部。<span style="font-size: 16pt; font-family: Eurostile; text-decoration: underline;">所以在接口中使用async是没有意义的，但是可以用async重载普通方法使其变成异步方法</span></span></div><div><span style="font-size: 16pt; font-family: Eurostile;"><img src="Evernote_files/Image [2].png" type="image/png" data-filename="Image.png" width="784"/></span></div><div><span style="font-size: 16pt;"><img src="Evernote_files/Image [3].png" type="image/png" data-filename="Image.png" width="713"/></span></div><div><font style="font-size: 16pt;"><br/></font></div><div>    </div><div><br/></div><div><br/></div><div><br/></div><div><br/></div><div><br/></div><div><br/></div><div><br/></div><div><br/></div><div><br/></div><div><br/></div></span>
</div>
<hr>
<a name="507"/>

<div>
<span><div><span style="font-size: 14pt; color: rgb(54, 101, 238); font-family: Eurostile;">ui窗体如何确定展示层级?</span></div><div><span style="font-size: 14pt; font-family: Eurostile;">依据路径加载的窗体,层级位置是由其wnd类决定的,在构造时传入的</span><span style="min-height: 11pt; font-size: 14pt; font-family: Eurostile;">EALUIWndLayer决定的.本质上在MGMainCameraMono上有设置该枚举对应的UI节点</span></div><div><span style="font-size: 14pt; color: rgb(54, 101, 238); font-family: Eurostile;">ui窗体的mono类路径名为什么用静态成员?</span></div><div><span style="font-size: 14pt; font-family: Eurostile;">依据路径加载的窗体流程,wnd类是先创建出来的,在load()的时候才会获取到mono类,所以设为将路径参数设为静态成员</span></div><div><font style="font-size: 14pt;"><span style="min-height: 11pt; font-size: 14pt; font-family: Eurostile;"><span style="font-size: 14pt; font-family: Eurostile; color: rgb(54, 101, 238);">关于绑定( 点击)拖动ui的原理:</span> </span></font></div><div><font face="Eurostile" style="font-size: 14pt;"><span style="min-height: 11pt; font-size: 14pt; font-family: Eurostile;">        combine时会调用getcomponent获取或者添加上边的类,拿到这个组件类后再regonclick,在可以操作的前提下,进行事件.</span><span style="min-height: 11pt; font-size: 14pt; font-family: Eurostile;">  </span></font></div><div><font face="Eurostile" style="font-size: 14pt;"><span style="min-height: 11pt; font-size: 14pt; font-family: Eurostile;">        在响应这个几拖动接口前会先判断该物体是否还有效             </span></font></div><div><font face="Eurostile" style="font-size: 14pt;"><span style="min-height: 11pt; font-size: 14pt; font-family: Eurostile;">            //判断是否可操作</span></font></div><div style="min-height: 11pt; text-align: left;"><span style="min-height: 11pt;"><span style="font-size: 14pt; font-family: Eurostile;">            Selectable selectableMono = GetComponent&lt;Selectable&gt;();</span></span></div><div style="min-height: 11pt; text-align: left;"><span style="min-height: 11pt; font-size: 14pt; font-family: Eurostile;">           </span> <span style="min-height: 11pt; font-size: 14pt; font-family: Eurostile;">if</span> <span style="min-height: 11pt; font-size: 14pt; font-family: Eurostile;">(</span><span style="min-height: 11pt; font-size: 14pt; font-family: Eurostile;">null</span> <span style="min-height: 11pt; font-size: 14pt; font-family: Eurostile;">!= selectableMono &amp;&amp; !selectableMono.interactable)</span></div><div style="min-height: 11pt; text-align: left;"><span style="min-height: 11pt; font-size: 14pt; font-family: Eurostile;">               </span> <span style="min-height: 11pt; font-size: 14pt; font-family: Eurostile;">return</span> <span style="min-height: 11pt; font-size: 14pt; font-family: Eurostile;">false</span><span style="min-height: 11pt; font-size: 14pt; font-family: Eurostile;">;</span></div><div style="min-height: 11pt; text-align: left;"><span style="min-height: 11pt; font-size: 14pt; font-family: Eurostile;">           </span> <span style="min-height: 11pt; font-size: 14pt; font-family: Eurostile;">return</span> <span style="min-height: 11pt; font-size: 14pt; font-family: Eurostile;">true</span><span style="min-height: 11pt; font-size: 14pt; font-family: Eurostile;">;</span></div><div style="min-height: 11pt; text-align: left;"><span style="color: rgb(54, 101, 238);">按钮类的自添加组件解析(UI点击事件监听)</span></div><div style="min-height: 11pt; text-align: left;"><span style="font-size: 14pt; min-height: 11pt; font-family: Eurostile;">ALUGUIEventTriggerListener:</span><span style="font-size: 14pt; min-height: 11pt; font-family: Eurostile;">MonoBehaviour, IPointerDownHandler, IPointerUpHandler, IPointerClickHandler, IMoveHandler.</span></div><div style="min-height: 11pt; text-align: left;"><span style="min-height: 11pt; font-size: 9.5pt; font-family: NSimSun;">   </span> <span style="min-height: 11pt; font-size: 9.5pt; color: rgb(0, 0, 255); font-family: NSimSun;">private</span> <span style="min-height: 11pt; font-size: 9.5pt; color: rgb(0, 0, 255); font-family: NSimSun;">static</span> <span style="min-height: 11pt; font-size: 9.5pt; color: rgb(0, 0, 255); font-family: NSimSun;">int</span> <span style="min-height: 11pt; font-size: 9.5pt; font-family: NSimSun;">_g_lastClickFrame;</span></div><div style="min-height: 11pt; text-align: left;"><span style="min-height: 11pt; font-size: 9.5pt; font-family: NSimSun;">   </span> <span style="min-height: 11pt; font-size: 9.5pt; color: rgb(128, 128, 128); font-family: NSimSun;">/**</span> <span style="min-height: 11pt; font-size: 9.5pt; color: rgb(0, 128, 0); font-family: NSimSun;">回调函数对象</span> <span style="min-height: 11pt; font-size: 9.5pt; color: rgb(128, 128, 128); font-family: NSimSun;">*/</span></div><div style="min-height: 11pt; text-align: left;"><span style="min-height: 11pt; font-size: 9.5pt; font-family: NSimSun;">   </span> <span style="min-height: 11pt; font-size: 9.5pt; color: rgb(0, 0, 255); font-family: NSimSun;">private</span> <span style="min-height: 11pt; font-size: 9.5pt; font-family: NSimSun;">Action&lt;GameObject&gt; _m_dOnClick;</span></div><div style="min-height: 11pt; text-align: left;"><span style="min-height: 11pt; font-size: 9.5pt; font-family: NSimSun;">   </span> <span style="min-height: 11pt; font-size: 9.5pt; color: rgb(0, 0, 255); font-family: NSimSun;">private</span> <span style="min-height: 11pt; font-size: 9.5pt; font-family: NSimSun;">Action&lt;</span><span style="min-height: 11pt; font-size: 9.5pt; color: rgb(0, 0, 255); font-family: NSimSun;">bool</span><span style="min-height: 11pt; font-size: 9.5pt; font-family: NSimSun;">, PointerEventData&gt; _m_dOnPress;</span></div><div style="min-height: 11pt; text-align: left;"><span style="min-height: 11pt; font-size: 9.5pt; font-family: NSimSun;">   </span> <span style="min-height: 11pt; font-size: 9.5pt; color: rgb(128, 128, 128); font-family: NSimSun;">/**</span> <span style="min-height: 11pt; font-size: 9.5pt; color: rgb(0, 128, 0); font-family: NSimSun;">长按事件</span> <span style="min-height: 11pt; font-size: 9.5pt; color: rgb(128, 128, 128); font-family: NSimSun;">*/</span></div><div style="min-height: 11pt; text-align: left;"><span style="min-height: 11pt; font-size: 9.5pt; font-family: NSimSun;">   </span> <span style="min-height: 11pt; font-size: 9.5pt; color: rgb(0, 0, 255); font-family: NSimSun;">private</span> <span style="min-height: 11pt; font-size: 9.5pt; font-family: NSimSun;">Action _m_dOnLongProess;</span></div><div style="min-height: 11pt; text-align: left;"><span style="min-height: 11pt; font-size: 9.5pt; font-family: NSimSun;">   </span> <span style="min-height: 11pt; font-size: 9.5pt; color: rgb(0, 0, 255); font-family: NSimSun;">private</span> <span style="min-height: 11pt; font-size: 9.5pt; color: rgb(0, 0, 255); font-family: NSimSun;">float</span> <span style="min-height: 11pt; font-size: 9.5pt; font-family: NSimSun;">_m_fLongPressDuration = 0.5f;</span><span style="min-height: 11pt; font-size: 9.5pt; color: rgb(0, 128, 0); font-family: NSimSun;">//长按事件触发的时间条件</span></div><div style="min-height: 11pt; text-align: left;"><span style="min-height: 11pt; font-size: 9.5pt; font-family: NSimSun;">   </span> <span style="min-height: 11pt; font-size: 9.5pt; color: rgb(0, 0, 255); font-family: NSimSun;">private</span> <span style="min-height: 11pt; font-size: 9.5pt; color: rgb(0, 0, 255); font-family: NSimSun;">bool</span> <span style="min-height: 11pt; font-size: 9.5pt; font-family: NSimSun;">_m_bIsMove =</span> <span style="min-height: 11pt; font-size: 9.5pt; color: rgb(0, 0, 255); font-family: NSimSun;">false</span><span style="min-height: 11pt; font-size: 9.5pt; font-family: NSimSun;">;</span><span style="min-height: 11pt; font-size: 9.5pt; color: rgb(0, 128, 0); font-family: NSimSun;">//是否移动了，当移动超出距离则不触发长按</span></div><div style="min-height: 11pt; text-align: left;"><span style="min-height: 11pt; font-size: 9.5pt; font-family: NSimSun;">   </span> <span style="min-height: 11pt; font-size: 9.5pt; color: rgb(0, 0, 255); font-family: NSimSun;">private</span> <span style="min-height: 11pt; font-size: 9.5pt; color: rgb(0, 0, 255); font-family: NSimSun;">int</span> <span style="min-height: 11pt; font-size: 9.5pt; font-family: NSimSun;">_m_iPointerId = -1;</span><span style="min-height: 11pt; font-size: 9.5pt; color: rgb(0, 128, 0); font-family: NSimSun;">//按下的操作点Id</span></div><div style="min-height: 11pt; text-align: left;"><span style="min-height: 11pt; font-size: 9.5pt; font-family: NSimSun;">   </span> <span style="min-height: 11pt; font-size: 9.5pt; color: rgb(0, 0, 255); font-family: NSimSun;">private</span> <span style="min-height: 11pt; font-size: 9.5pt; color: rgb(0, 0, 255); font-family: NSimSun;">bool</span> <span style="min-height: 11pt; font-size: 9.5pt; font-family: NSimSun;">_m_bIsPointerDown =</span> <span style="min-height: 11pt; font-size: 9.5pt; color: rgb(0, 0, 255); font-family: NSimSun;">false</span><span style="min-height: 11pt; font-size: 9.5pt; font-family: NSimSun;">;</span><span style="min-height: 11pt; font-size: 9.5pt; color: rgb(0, 128, 0); font-family: NSimSun;">//是否按下</span></div><div style="min-height: 11pt; text-align: left;"><span style="min-height: 11pt; font-size: 9.5pt; font-family: NSimSun;">   </span> <span style="min-height: 11pt; font-size: 9.5pt; color: rgb(0, 0, 255); font-family: NSimSun;">private</span> <span style="min-height: 11pt; font-size: 9.5pt; color: rgb(0, 0, 255); font-family: NSimSun;">bool</span> <span style="min-height: 11pt; font-size: 9.5pt; font-family: NSimSun;">_m_bLongPressTriggered =</span> <span style="min-height: 11pt; font-size: 9.5pt; color: rgb(0, 0, 255); font-family: NSimSun;">false</span><span style="min-height: 11pt; font-size: 9.5pt; font-family: NSimSun;">;</span><span style="min-height: 11pt; font-size: 9.5pt; color: rgb(0, 128, 0); font-family: NSimSun;">//长按事件是否触发</span></div><div style="min-height: 11pt; text-align: left;"><span style="min-height: 11pt; font-size: 9.5pt; font-family: NSimSun;">   </span> <span style="min-height: 11pt; font-size: 9.5pt; color: rgb(0, 0, 255); font-family: NSimSun;">private</span> <span style="min-height: 11pt; font-size: 9.5pt; color: rgb(0, 0, 255); font-family: NSimSun;">float</span> <span style="min-height: 11pt; font-size: 9.5pt; font-family: NSimSun;">_m_fLongPressTriggerTime;</span><span style="min-height: 11pt; font-size: 9.5pt; color: rgb(0, 128, 0); font-family: NSimSun;">//触发长按的时间标记</span></div><div style="min-height: 11pt; text-align: left;"><span style="min-height: 11pt; font-size: 9.5pt; font-family: NSimSun;">   </span> <span style="min-height: 11pt; font-size: 9.5pt; color: rgb(0, 0, 255); font-family: NSimSun;">private</span> <span style="min-height: 11pt; font-size: 9.5pt; color: rgb(0, 0, 255); font-family: NSimSun;">bool</span> <span style="min-height: 11pt; font-size: 9.5pt; font-family: NSimSun;">_m_bTriggerPointerEventAgain =</span> <span style="min-height: 11pt; font-size: 9.5pt; color: rgb(0, 0, 255); font-family: NSimSun;">false</span><span style="min-height: 11pt; font-size: 9.5pt; font-family: NSimSun;">;</span><span style="min-height: 11pt; font-size: 9.5pt; color: rgb(0, 128, 0); font-family: NSimSun;">//是否重新触发PointerDown/Up/Click事件，让被盖住的UI也能监听到</span></div><div style="min-height: 11pt; text-align: left;"><span style="min-height: 11pt; font-size: 9.5pt; font-family: NSimSun;">   </span> <span style="min-height: 11pt; font-size: 9.5pt; color: rgb(0, 0, 255); font-family: NSimSun;">private</span> <span style="min-height: 11pt; font-size: 9.5pt; color: rgb(0, 0, 255); font-family: NSimSun;">int</span> <span style="min-height: 11pt; font-size: 9.5pt; font-family: NSimSun;">_m_iOneClickPerFrame = ALConst.CLICK_INTERVAL_FRAME;</span><span style="min-height: 11pt; font-size: 9.5pt; color: rgb(0, 128, 0); font-family: NSimSun;">//是否每帧只触发一次点击</span></div><div style="min-height: 11pt; text-align: left;"><span style="min-height: 11pt; font-size: 9.5pt; font-family: NSimSun;">   </span> <span style="min-height: 11pt; font-size: 9.5pt; color: rgb(0, 0, 255); font-family: NSimSun;">private</span> <span style="min-height: 11pt; font-size: 9.5pt; font-family: NSimSun;">Vector2 _m_vPressPos;</span></div><div style="min-height: 11pt; text-align: left;"><span style="min-height: 11pt; font-size: 9.5pt; font-family: NSimSun;">   </span> <span style="min-height: 11pt; font-size: 9.5pt; color: rgb(0, 0, 255); font-family: NSimSun;">private</span> <span style="min-height: 11pt; font-size: 9.5pt; font-family: NSimSun;">Vector2 _m_vTempMovDis;</span></div><div style="min-height: 11pt; text-align: left;"><font face="Eurostile" style="font-size: 14pt;"><span style="min-height: 11pt; font-size: 14pt; font-family: Eurostile;">这个类每当有UI物体绑定的时候都会添加上去,有两个可选参数:1.点击间隔(指定帧数) 和 2.使被盖住的UI也能监听到点击事件</span></font></div><div style="min-height: 11pt; text-align: left;"><font face="Eurostile" style="font-size: 14pt;"><span style="min-height: 11pt; font-size: 14pt; font-family: Eurostile;">                1.</span></font><font style="font-size: 14pt;"><span style="min-height: 11pt; font-size: 14pt; font-family: Eurostile;">点击间隔实现原理:(</span></font><span style="min-height: 11pt; font-size: 9.5pt; color: rgb(43, 145, 175); font-family: NSimSun;">IPointerClickHandler实现</span><font style="font-size: 14pt;"><span style="min-height: 11pt; font-size: 14pt; font-family: Eurostile;">)</span></font></div><div style="min-height: 11pt; text-align: left;"><font face="Eurostile" style="font-size: 14pt;"><span style="min-height: 11pt; font-size: 14pt; font-family: Eurostile;">                    这个组件有个静态int标志位: 最后一次点击时的帧数.</span></font>Time.frameCount;这个是设置每多少帧可以点击按钮的功能;在每次pointClick的回调中记录上次点击的帧数和当前游戏帧数对比,差值小于限定帧数内则不做操作</div><div style="min-height: 11pt; text-align: left;"><span style="min-height: 11pt;"><span style="font-size: 14pt; font-family: Eurostile;">    </span><span style="font-size: 14pt; font-family: Eurostile;">    </span><span style="font-size: 14pt; font-family: Eurostile;">  </span> <span style="font-size: 11pt; font-family: Eurostile;">        </span> <span style="font-size: 11pt; font-family: Eurostile;">当</span></span><font face="Eurostile" style="font-size: 11pt;"><span style="min-height: 11pt; font-size: 11pt; font-family: Eurostile; color: rgb(43, 145, 175);">IPointerClickHandler被触发时</span><span style="min-height: 11pt; font-size: 11pt; font-family: Eurostile;">OnPointerClick() 经过:判断物体是否可以操作=&gt;判断操作id(eventData.pointerid)=&gt;判断是否属于长按操作=&gt;逻辑:</span></font></div><div style="min-height: 11pt; text-align: left;"><font face="Eurostile" style="font-size: 11pt;"><span style="min-height: 11pt; font-size: 11pt; font-family: Eurostile;">                        记录当前帧数(</span><span style="min-height: 11pt; font-size: 11pt; font-family: Eurostile;">Time.frameCount</span></font><span style="min-height: 11pt;"><span style="font-size: 11pt; font-family: Eurostile;">) 和 静态标准位对比 如果两者相差大于</span> <span style="font-size: 11pt; font-family: Eurostile; font-weight: bold;">间隔指定帧数</span> <span style="font-size: 11pt; font-family: Eurostile;">就会更新静态标志位,执行点击事件.否则直接return.</span><span style="font-size: 11pt; font-family: Eurostile; font-weight: bold;"> </span></span></div><div style="min-height: 11pt; text-align: left;"><font face="Eurostile" style="font-size: 14pt;"><span style="min-height: 11pt; font-size: 14pt; font-family: Eurostile;">                2.</span></font><span style="font-size: 14pt; min-height: 11pt; font-family: Eurostile;">穿透按钮事件:</span></div><div style="min-height: 11pt; text-align: left;"><span style="min-height: 11pt; font-size: 14pt; font-family: Eurostile;">                    // 官方文档:</span> <span style="letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(240, 240, 240); font-size: 14pt; font-family: Eurostile; font-variant-caps: normal; font-variant-ligatures: normal;">向上递归调用 Execute&lt;T&gt; 的层级视图，直到有可以处理该事件的游戏对象</span></div><div><span style="min-height: 11pt;"><span style="font-size: 14pt; font-family: Eurostile;">                    ExecuteEvents.ExecuteHierarchy(transform.parent.gameObject, eventData, ExecuteEvents.pointerUpHandler);</span></span></div><div><span style="min-height: 11pt; font-size: 9.5pt;"><span style="font-size: 14pt; font-family: Eurostile;">                </span></span><span style="min-height: 11pt; font-size: 9.5pt; font-family: Eurostile;">IMoveHandler实现: 在没有按下且没有触发长按时,会对比触发pointDown的</span><span style="min-height: 11pt; font-size: 9.5pt; font-family: Eurostile;">eventData.pressPosition 和 当前接口的</span><span style="min-height: 11pt; font-size: 9.5pt; font-family: Eurostile;">eventData.</span><span style="min-height: 11pt; font-size: 9.5pt; font-family: Eurostile;">moveVector计算距离偏差大于屏幕的1/20就算移动.</span></div><div><span style="min-height: 11pt; font-size: 9.5pt;"><span style="font-size: 9.5pt; font-family: Eurostile;">                        </span></span><span style="min-height: 11pt; font-size: 9.5pt;"><span style="font-size: 9.5pt; font-family: Eurostile;">IPointerDownHandler实现: 判断物体是否可以操作=&gt;!判断是否已经有按钮按下,之后会将</span> <span style="font-size: 9.5pt; font-family: Eurostile; font-weight: bold;">是否移动置否 ,将长按标记置否,将是否点击置真,记录按下位置,</span></span><span style="min-height: 11pt; font-size: 9.5pt;"><span style="font-size: 9.5pt; font-family: Eurostile; font-weight: bold;">记录pointerId, 除此之外还会设置长按的参数:</span></span></div><div><span style="min-height: 11pt;"><span style="font-size: 9pt; font-family: Eurostile; font-weight: bold;">                </span><span style="font-size: 10pt; font-family: Eurostile; font-weight: bold;">            </span></span><font style="font-size: 10pt;"><span style="min-height: 11pt; font-size: 10pt; font-family: Eurostile;"> 长按触发时间 = </span><span style="min-height: 11pt; font-size: 10pt; font-family: Eurostile;">Time.unscaledTime + 长按触发条件时间(0.5f).之后执行按下按钮事件,之后判断是否有穿透属性.</span></font></div><div><font face="Eurostile" style="font-size: 10pt;"><span style="min-height: 11pt; font-size: 10pt; font-family: Eurostile;">                       </span><span style="min-height: 11pt; font-size: 10pt; font-family: Eurostile; color: rgb(43, 145, 175);">IPointerUpHandler</span><span style="min-height: 11pt; font-size: 10pt; font-family: Eurostile;">实现: 如果没有按键按下就不处理.判断操作id是否一致,之后重置参数:是否移动置否,是否按下置否,长按条件置零.之后执行抬起事件</span></font><span style="min-height: 11pt;"><span style="font-size: 10pt; font-family: Eurostile;"> ,最后判断是否有穿透属性</span></span></div><div><font face="Eurostile" style="font-size: 14pt;"><span style="min-height: 11pt;"><span style="font-size: 14pt; font-family: Eurostile;">                3.在Update中实现长按的判断: 在按钮按下且未移动且未触发长按事件的前提下,</span></span><span style="min-height: 11pt; font-size: 14pt; font-family: Eurostile;">Time.unscaledTime大于等于长按条件时间时执行长按事件</span></font></div><div><br/></div><div><span style="min-height: 11pt; font-size: 14pt; color: rgb(54, 101, 238); font-family: Eurostile;">场景附加加载:</span><span style="min-height: 11pt; font-size: 14pt; font-family: Eurostile;">Scene newScene = SceneManager.LoadScene(_sceneName,</span> <span style="min-height: 11pt; font-size: 14pt; color: rgb(0, 0, 255); font-family: Eurostile;">new</span> <span style="min-height: 11pt; font-size: 14pt; font-family: Eurostile;">LoadSceneParameters(LoadSceneMode.Additive));最后的参数就是设置附加场景.</span></div><div><span style="min-height: 11pt; font-size: 14pt; font-family: Eurostile;">在</span><span style="min-height: 11pt; font-size: 9.5pt; color: rgb(43, 145, 175); font-family: NSimSun;">ALSceneMgr中</span></div><div><span style="font-size: 11.3pt; color: rgb(78, 201, 176); font-family: Eurostile;">TMP_ObjectPool</span></div><div><span style="min-height: 11pt;"><span style="font-size: 14pt; font-family: Eurostile;">在方法中使用完临时变量后可以直接设null</span></span></div><div>/** 获取是否可操作 */</div><div>protected bool _interactable</div><div>{</div><div>get</div><div>{</div><div>//判断是否可操作</div><div>Selectable selectableMono = GetComponent&lt;Selectable&gt;();</div><div>if (null != selectableMono &amp;&amp; !selectableMono.interactable)</div><div>return false;</div><div><br/></div><div>return true;</div><div>}</div><div>}</div><div><span style="min-height: 11pt; font-size: 9.5pt; font-family: NSimSun;">        </span></div><div><br/></div><div><span style="min-height: 11pt; font-size: 9.5pt;"><br/></span></div><div><span style="font-size: 9pt;">总共有三种ui事件监听脚本</span></div><div><span style="font-size: 9pt;">pointListener : pointEnter,pointExit,pointup,pointDown</span></div><div><span style="font-size: 9pt;">drawListener : beginDrag,drag,endDrag,move</span></div><div><span style="font-size: 9pt;">triggerListener: </span><span style="font-size: 14pt; min-height: 11pt; font-family: Eurostile;">IPointerDownHandler, IPointerUpHandler, IPointerClickHandler, IMoveHandler.</span></div><div><span style="font-size: 14pt; min-height: 11pt;"><br/></span></div><div>输入接口所需的行为</div><div><span style="min-height: 11pt; font-size: 9.5pt;"><br/></span></div><div><span style="min-height: 11pt; font-size: 9.5pt;"><br/></span></div><div><span style="min-height: 11pt; font-size: 9.5pt;"><br/></span></div><div><span style="min-height: 11pt; font-size: 9.5pt;"><br/></span></div><div><span style="min-height: 11pt; font-size: 9.5pt;"><br/></span></div></span>
</div>
<hr>
<a name="509"/>

<div>
<span><div>UI架构(MVC框架) <a href="https://www.jianshu.com/p/b0aab1ffad93">mvc和mvvm的区别 - 简书 (jianshu.com)</a></div><div>    view层:界面表现层,需要挂载在UI资源上,主要功能是提供给 <span style="font-size: medium; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; color: rgb(18, 18, 18); font-family: -apple-system, BlinkMacSystemFont, &quot;Helvetica Neue&quot;, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Source Han Sans SC&quot;, &quot;Noto Sans CJK SC&quot;, &quot;WenQuanYi Micro Hei&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">Controller层UI组件的引用地址,以及UI表现</span></div><div><span style="font-size: medium; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; color: rgb(18, 18, 18); font-family: -apple-system, BlinkMacSystemFont, &quot;Helvetica Neue&quot;, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Source Han Sans SC&quot;, &quot;Noto Sans CJK SC&quot;, &quot;WenQuanYi Micro Hei&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">    Controller层:界面逻辑层,下文主要阐述的内容.功能是获取modle层的数据然后通知UI做表现</span></div><div>    <span style="font-size: medium; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; color: rgb(18, 18, 18); font-family: -apple-system, BlinkMacSystemFont, &quot;Helvetica Neue&quot;, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Source Han Sans SC&quot;, &quot;Noto Sans CJK SC&quot;, &quot;WenQuanYi Micro Hei&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">modle层:数据存储层,各个业务的数据处理层</span></div><div><span style="font-size: medium; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><br/></span></div><div>    UI分为 通过资源加载的wnd; 懒加载的PrefabWnd(需要用到时才通过资源路径加载的,作为wnd的子窗体存在);无需资源加载的SubWnd(依托于wnd加载时一同加载上去)</div><div>    <span style="min-height: 11pt; font-size: 9.5pt; color: rgb(0, 128, 0); font-family: NSimSun;">UIInterface:行为: show hide reset discard getGameobj </span></div><div><span style="min-height: 11pt; font-size: 9.5pt; color: rgb(0, 128, 0); font-family: NSimSun;"> 窗体的行为可以大致归纳为 初始化(只执行一次类似awake),展示,隐藏,重置和摧毁</span></div><div><span style="min-height: 11pt; font-size: 9.5pt; color: rgb(0, 128, 0); font-family: NSimSun;"> </span></div><div><span style="font-size: medium; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; color: rgb(18, 18, 18); font-family: -apple-system, BlinkMacSystemFont, &quot;Helvetica Neue&quot;, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Source Han Sans SC&quot;, &quot;Noto Sans CJK SC&quot;, &quot;WenQuanYi Micro Hei&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">    Controller层介绍:</span></div><div><br/></div><div>    SubWnd: <span style="min-height: 11pt; font-size: 9.5pt; color: rgb(0, 128, 0); font-family: NSimSun;">ui中窗口中的子窗口类对象，此对象不会进行加载操作，所带入的窗口对象不进行资源释放，具体资源由外部控制.直接继承UIInterface的接口</span></div><div><span style="min-height: 11pt; font-size: 9.5pt; color: rgb(0, 128, 0); font-family: NSimSun;">    在构造函数中传入view类.</span></div><div><span style="min-height: 11pt; font-size: 9.5pt;"><span style="font-size: 9.5pt; font-family: NSimSun;"> </span><span style="font-size: 9.5pt; font-family: Ebrima;">prefabWnd: 继承loadObj 和 UIInterface接口,加载的本质和wnd没有区别都是通过路径名进行加载的.但是构造方式有区别,</span></span><span style="min-height: 11pt; font-size: 9.5pt; font-family: Ebrima;">prefabWnd在构造时需要传入父节点,而wnd是传层级枚举,层级枚举最后还是去获取UIroot的父节点</span></div><div><span style="min-height: 11pt; font-size: 9.5pt; font-family: Ebrima;"><br/></span></div><div><span style="min-height: 11pt; font-size: 9.5pt; font-family: Ebrima;"><span>    </span>wnd: 在介绍该内容时,需要再阐述一下UI窗体的定义:UI窗体是提供人机交互功能的游戏资源.它是具有UiInterface的行为的游戏资源.一般是需要通过加载手段实例化的</span></div></span>
</div>
<hr>
<a name="511"/>

<div>
<span><div>c#语法内容:</div><div><span style="min-height: 11pt; font-family: NSimSun; font-size: 9.5pt;">Enumerable.Range(0, 30)==&gt;生成数列</span></div><div><br/></div><div><br/></div><div>接口interface</div><div>    实现接口的类中,只要拥有接口要求的内容就算实现</div><div>    <span style="min-height: 11pt; font-size: 9.5pt; font-family: NSimSun;">      </span><span style="min-height: 11pt; font-size: 9.5pt; color: rgb(0, 0, 255); font-family: NSimSun;">public</span> <span style="min-height: 11pt; font-size: 9.5pt; color: rgb(0, 0, 255); font-family: NSimSun;">interface</span> <span style="min-height: 11pt; font-size: 9.5pt; color: rgb(43, 145, 175); font-family: NSimSun;">ITest</span></div><div style="min-height: 11pt; text-align: left;"><span style="min-height: 11pt; font-size: 9.5pt; font-family: NSimSun;">        {</span></div><div style="min-height: 11pt; text-align: left;"><span style="min-height: 11pt; font-size: 9.5pt; font-family: NSimSun;">           </span> <span style="min-height: 11pt; font-size: 9.5pt; color: rgb(0, 0, 255); font-family: NSimSun;">void</span> <span style="min-height: 11pt; font-size: 9.5pt; font-family: NSimSun;">Fun1();</span></div><div style="min-height: 11pt; text-align: left;"><span style="min-height: 11pt; font-size: 9.5pt; font-family: NSimSun;">        }</span></div><div style="min-height: 11pt; text-align: left;"><span style="min-height: 11pt; font-size: 9.5pt; font-family: NSimSun;">       </span> <span style="min-height: 11pt; font-size: 9.5pt; color: rgb(0, 0, 255); font-family: NSimSun;">public</span> <span style="min-height: 11pt; font-size: 9.5pt; color: rgb(0, 0, 255); font-family: NSimSun;">class</span> <span style="min-height: 11pt; font-size: 9.5pt; color: rgb(43, 145, 175); font-family: NSimSun;">A0</span></div><div style="min-height: 11pt; text-align: left;"><span style="min-height: 11pt; font-size: 9.5pt; font-family: NSimSun;">        {</span></div><div style="min-height: 11pt; text-align: left;"><span style="min-height: 11pt; font-size: 9.5pt; font-family: NSimSun;">           </span> <span style="min-height: 11pt; font-size: 9.5pt; color: rgb(0, 0, 255); font-family: NSimSun;">public</span> <span style="min-height: 11pt; font-size: 9.5pt; color: rgb(0, 0, 255); font-family: NSimSun;">virtual</span> <span style="min-height: 11pt; font-size: 9.5pt; color: rgb(0, 0, 255); font-family: NSimSun;">void</span> <span style="min-height: 11pt; font-size: 9.5pt; font-family: NSimSun;">Fun1()//在父类中拥有和接口同名的方法</span></div><div style="min-height: 11pt; text-align: left;"><span style="min-height: 11pt; font-size: 9.5pt; font-family: NSimSun;">            {</span></div><div style="min-height: 11pt; text-align: left;"><span style="min-height: 11pt; font-size: 9.5pt; font-family: NSimSun;">                Console.WriteLine(</span><span style="min-height: 11pt; font-size: 9.5pt; color: rgb(163, 21, 21); font-family: NSimSun;">&quot;====&quot;</span><span style="min-height: 11pt; font-size: 9.5pt; font-family: NSimSun;">);</span></div><div style="min-height: 11pt; text-align: left;"><span style="min-height: 11pt; font-size: 9.5pt; font-family: NSimSun;">            }</span></div><div style="min-height: 11pt; text-align: left;"><span style="min-height: 11pt; font-size: 9.5pt; font-family: NSimSun;">        }</span></div><div style="min-height: 11pt; text-align: left;"><span style="min-height: 11pt; font-size: 9.5pt; font-family: NSimSun;">       </span> <span style="min-height: 11pt; font-size: 9.5pt; color: rgb(0, 0, 255); font-family: NSimSun;">public</span> <span style="min-height: 11pt; font-size: 9.5pt; color: rgb(0, 0, 255); font-family: NSimSun;">class</span> <span style="min-height: 11pt; font-size: 9.5pt; color: rgb(43, 145, 175); font-family: NSimSun;">A1</span> <span style="min-height: 11pt; font-size: 9.5pt; font-family: NSimSun;">: A0, ITest//子类继承了父类的方法默认实现了接口</span></div><div style="min-height: 11pt; text-align: left;"><span style="min-height: 11pt; font-size: 9.5pt; font-family: NSimSun;">        {</span></div><div style="min-height: 11pt; text-align: left;"><span style="min-height: 11pt; font-size: 9.5pt; font-family: NSimSun;">           </span></div><div style="min-height: 11pt; text-align: left;"><span style="min-height: 11pt; font-size: 9.5pt; font-family: NSimSun;">        }</span></div><div style="min-height: 11pt; text-align: left;"><span style="font-size: unset;"><br/></span></div><div style="min-height: 11pt; text-align: left;"><span style="font-size: unset; color: unset; font-family: unset;">泛型方法可以限定目标类型</span></div></span>
</div>
<hr>
<a name="513"/>

<div>
<span><div><div><div><div>设计模式</div><div>耦合关系直接决定软件面对变化时的行为</div><div>    从目的上可以分为三种：</div><div>        创建型：负责创建对象；结构型： 负责处理类与对象间的组合；行为型：负责处理类与对像中的职责分配</div><div>    从范围上看：</div><div>        类模式处理类与子类的静态关系</div><div>        对象模式处理对象间的动态关系没见你 </div><div><img src="Evernote_files/Image [4].png" type="image/png" data-filename="Image.png" width="506"/></div><div>单例模式： 提供一种机制保证一个类只有一个实例 ==&gt; 这是类设计者的责任，而不是使用者的责任</div><div>    最好添加一个私有或保护构造器，让使用者不会去new这个类：如果不写构造器，编译器会自行提供一个共有无参缺省的构造器。</div><div>    一般不要支持Icloneable接口；一般不要支持序列化（因为序列化也可以构造出对象）；</div><div>    考虑多线程下的变量加锁</div><div>  <span style="font-weight: bold;">  #内联概念</span></div><div><br/></div><hr/><div>抽象工厂</div><div>经常面临着“一系列相互依赖的对象”的创建工作，但是由于需求的变化，往往存在更多系列对象的创建工作</div><div>new问题：实现依赖，不能应对“具体实例化类型”的变化</div><div>思路：封装变化点，如果没有变化不需要额外封装</div><div><img src="Evernote_files/Image [5].png" type="image/png" data-filename="Image.png" width="741"/></div><div>可以通过动态的配置文件不用改代码</div><div>值得注意的是Abs工厂模式主要应对“新系列”(factory)的需求变动，难以应对“新对象”（product)变动；当在抽象系统中变更产品时反而要花更多的精力去维护代码</div><div>但是只是单单系统风格变更abs工厂能很轻松应对</div><div><br/></div><hr/><div>bulider模式</div><div>在系统中，有时候面临着“一个复杂对象”的创建工作，其通常由各个子对象用一定的算法组成；由于需求变化，这个系统的哥哥部分会面临剧烈变更，但是将他们组合在一起的部分却相对稳定</div><div>核心：提供一种封装机制来隔离复杂对象的各个部分变化，从而保持系统中稳定构建算法不随需求改变而改变</div><div><img src="Evernote_files/Image [6].png" type="image/png" data-filename="Image.png" width="740"/></div><div>这个模式主要用于分步骤的构建一个复杂的系统。在这其中&quot;分步骤&quot;是一个稳定的，而复杂对象的各个部分是经常变化</div><div>主要是应对复杂对象各个部分的需求变更，难以应对分步骤的算法变动</div><div>#abs工厂解决系统对象的需求变化，builder解决对象部分的需求变化。这个两个模式对新的子对象扩展都比较困难</div><div><br/></div><div><br/></div></div><hr/><div>工厂方法</div><div><img src="Evernote_files/Image [7].png" type="image/png" data-filename="Image.png"/></div><div>switch 的是简单工厂类</div><div><br/></div></div><hr/><div>依赖倒置： 抽象不应该依赖实现细节，实现细节应该依赖抽象</div><div>原型设计模式：在软件系统中经常有结构复杂的对象创建工作；由于需求变化，这些对象经常面临着剧烈变化，但是却它拥有比较稳定的对外接口。如何向“客户程序”隔离出这些易变的对象，从而使得依赖这些对象的客户程序不随着需求改变而改变？</div><div><img src="Evernote_files/Image [8].png" type="image/png" data-filename="Image.png" width="924"/></div><div>为啥要用？ <span style="font-size: 16px; box-sizing: border-box; outline: 0px; overflow-wrap: break-word; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; color: rgb(77, 77, 77); font-family: -apple-system, &quot;SF UI Text&quot;, Arial, &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, &quot;WenQuanYi Micro Hei&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: no-common-ligatures; font-weight: bold;">一般情况，在初始化的信息不变的情况下，克隆是最好的办法。这既隐藏了</span><span style="font-size: 16px; color: rgb(77, 77, 77); font-family: -apple-system, &quot;SF UI Text&quot;, Arial, &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, &quot;WenQuanYi Micro Hei&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: no-common-ligatures; font-weight: bold; text-decoration: underline;">对象创建的细节</span><span style="font-size: 16px; box-sizing: border-box; outline: 0px; overflow-wrap: break-word; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; color: rgb(77, 77, 77); font-family: -apple-system, &quot;SF UI Text&quot;, Arial, &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, &quot;WenQuanYi Micro Hei&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: no-common-ligatures; font-weight: bold;">，又对性能做了很大的提升</span></div><div>关于拷贝：浅拷贝和深拷贝</div><div>    浅拷贝： <span style="font-size: 14px; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; color: rgb(68, 68, 68); font-family: Tahoma, Arial, Helvetica, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">在C#中调用 MemberwiseClone() 方法即为浅复制。如果字段是子类型则对字段进行逐位复制，引用类型则复制对象引用。</span></div><div>    深拷贝：首先将对象序列化到内存中,然后将内存流中的状态信息反序列化到一个新的对象中</div><div> string类型的特殊性： <span style="font-size: 16px; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; color: rgb(79, 79, 79); font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, SimHei, Arial, SimSun; font-variant-caps: normal; font-variant-ligatures: normal;">string 对象称为不可变的（只读），因为一旦创建了该对象，就不能修改该对象的值。</span> <span style="font-size: 16px; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; color: rgb(79, 79, 79); font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, SimHei, Arial, SimSun; font-variant-caps: normal; font-variant-ligatures: normal;">每次改变值时都会建立一个新的string对象，变量会指向这个新的对象，而原来的还是指向原来的对象，所以不会改变</span></div><div><span style="font-size: 16px; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><br/></span></div><div><span style="font-size: 16px; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255); color: rgb(49, 70, 89); font-family: Lato, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">原型模式可扩展为带原型管理器的原型模式，它</span><span style="font-size: 16px; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255); color: rgb(49, 70, 89); font-family: Lato, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: bold;">在原型模式的基础上增加了一个原型管理器 PrototypeManager 类</span><span style="font-size: 16px; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; color: rgb(49, 70, 89); font-family: Lato, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">。该类用 Dictionary（或HashMap） 保存多个复制的原型，Client 类可以通过管理器的 Get(String id) 方法从中获取复制的原型。</span></div><div><span style="font-size: 12pt; color: rgb(79, 79, 79); font-family: &quot;PingFang SC&quot;;"><img src="Evernote_files/Image [9].png" type="image/png" data-filename="Image.png" width="721"/></span></div><div><span style="font-size: 16px; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><br/></span></div><div><img src="Evernote_files/Image [10].png" type="image/png" data-filename="Image.png" width="517"/></div><div><br/></div><div><br/></div></div><div><br/></div></span>
</div>
<hr>
<a name="529"/>

<div>
<span><div><div>anchor(锚点):ui中四个花瓣表示；是针对于父物体的对齐方式。</div><div>   1. 当锚点聚合在一起时：基本的rect参数为 <span style="text-decoration: underline;">pos_x ,pox_y,width,height</span> 此时该物体的pos x,y的数值是<span style="font-weight: bold;">轴心点（pivot）对于 </span><span style="font-weight: bold;">锚点</span>的相对坐标。width和height代表该ui的宽高</div><div>   2.当锚点左右分开，上下集合时；说明<span style="font-weight: bold;">ui在x方向的大小是不固定的</span>，是适配的：基本的rect参数为<span style="text-decoration: underline;">left,reght,Pos_y,Height</span>，left和right是相对于左右锚点的距离，Pos_y代表轴心点对于两个锚点连线的距离，height就是ui的y方向的大小</div><div>   3.当锚点上下分开，左右集合时：说明<span style="font-weight: bold;">ui在y方向的大小是不固定的</span>：基本的rect参数为t<span style="text-decoration: underline;">op,bottom,Pos_x,width,top</span>和bottom是相对与上下锚点的距离，pos_x代表轴心点对于两个锚点连线的距离，width是ui的x方向的大小</div><div>    4.当锚点上下左右都分开：说明ui的在xy上的方向都是不固定的: 基本的rect参数为<span style="text-decoration: underline;">top,bottom,eft,reght.</span></div><div><br/></div><div><br/></div><div><span style="text-decoration: underline;"><img src="Evernote_files/Image [11].png" type="image/png" data-filename="Image.png" width="310"/></span><img src="Evernote_files/Image [12].png" type="image/png" data-filename="Image.png"/>这个就是锚点的位置属性</div><div><br/></div><div>在debug模式下：</div><div>ui的localPosition是表示该ui的轴心点相对于父物体轴心点的位置</div><div><img src="Evernote_files/Image [13].png" type="image/png" data-filename="Image.png" width="556"/></div><div><br/></div><div>anchor position是ui轴心点相对于锚点几何意义中心的位置</div><div><img src="Evernote_files/Image [14].png" type="image/png" data-filename="Image.png" width="554"/> </div><div><br/></div><div>关于canvas scaler中 图片像素和unity的尺寸大小关系</div><div>constant pixel sixe：中的scale factor 可以做自适应</div><div><br/></div><div>Graphic Raycaster :ui的射线检测。参数：1.是否相应反转的物体（rocation_y = 180）2.哪种类型的物体可以遮挡射线3.能够遮挡射线的层级</div><div>canvas Group: 控制子物体的属性；透明通道，是否可交互，是否能接受图形射线的检测，是否忽略父组件的canvas group的影响</div><div><br/></div><div>UI渲染层级</div><div>想要两个相机的画面喧染到一起，需要设置clear flars 为depth only。此时多个摄像机渲染的顺序由depth决定数字越大越在上层。在camera模式下的canvas有两个决定层级的属性sorting_layer和order_in_layer这两个属性同样是数字越大，渲染层级越高。ui上也可以挂载上canvas去该边渲染层级顺序，当两个ui的这两个参数都相同的话，在编辑器的自然顺序决定哪个物体先渲染</div><div>Image 附上图片之后的image_type: simaple（普通模式） ，九宫模式Sliced，平铺模式Tiled,逐渐填充模式filled</div><div>RaeI mage 可以让3d模型展示</div><div> 的UVRect可以选定需要展示的纹理的部分以及展示的大小，x，y都是0·1的浮点型</div><div><br/></div><div>点击事件关注点</div><div>当父物体实现pointup pointDown和click事件，但是子物体只实现click事件时。点击子物体是不会执行该click,只会执行父物体的up&amp;down</div><h3 style="box-sizing: border-box; border-width: 0px; border-style: solid; border-color: rgb(229, 231, 235); --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgb(59 130 246 / .5); --tw-ring-offset-shadow: 0 0 #0000; --tw-ring-shadow: 0 0 #0000; --tw-shadow: 0 0 #0000; --tw-shadow-colored: 0 0 #0000; font-size: 1.25em; margin: 24px 0px 16px; line-height: 1.25; color: rgb(36, 41, 47); font-family: -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, &quot;Noto Sans&quot;, Helvetica, Arial, sans-serif, &quot;Apple Color Emoji&quot;, &quot;Segoe UI Emoji&quot;; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(244, 246, 248);"><span style="box-sizing: border-box; border-width: 0px; border-style: solid; border-color: rgb(229, 231, 235); --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgb(59 130 246 / .5); --tw-ring-offset-shadow: 0 0 #0000; --tw-ring-shadow: 0 0 #0000; --tw-shadow: 0 0 #0000; --tw-shadow-colored: 0 0 #0000; font-size: 1.25em; line-height: 1.25; color: rgb(36, 41, 47); font-family: -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, &quot;Noto Sans&quot;, Helvetica, Arial, sans-serif, &quot;Apple Color Emoji&quot;, &quot;Segoe UI Emoji&quot;; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(244, 246, 248);">1. Anchor（锚点）</span></h3><div style="box-sizing: border-box; border-width: 0px; border-style: solid; border-color: rgb(229, 231, 235); --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgb(59 130 246 / 0.5); --tw-ring-offset-shadow: 0 0 #0000; --tw-ring-shadow: 0 0 #0000; --tw-shadow: 0 0 #0000; --tw-shadow-colored: 0 0 #0000; margin: 0px 0px 16px; white-space: pre-wrap; color: rgb(36, 41, 47); font-family: -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, &quot;Noto Sans&quot;, Helvetica, Arial, sans-serif, &quot;Apple Color Emoji&quot;, &quot;Segoe UI Emoji&quot;; font-size: 14px; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(244, 246, 248);"><span style="box-sizing: border-box; border-width: 0px; border-style: solid; border-color: rgb(229, 231, 235); --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgb(59 130 246 / .5); --tw-ring-offset-shadow: 0 0 #0000; --tw-ring-shadow: 0 0 #0000; --tw-shadow: 0 0 #0000; --tw-shadow-colored: 0 0 #0000; white-space: pre-wrap; color: rgb(36, 41, 47); font-family: -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, &quot;Noto Sans&quot;, Helvetica, Arial, sans-serif, &quot;Apple Color Emoji&quot;, &quot;Segoe UI Emoji&quot;; font-size: 14px; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(244, 246, 248); font-weight: bold;">定义</span><span style="box-sizing: border-box; border-width: 0px; border-style: solid; border-color: rgb(229, 231, 235); --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgb(59 130 246 / 0.5); --tw-ring-offset-shadow: 0 0 #0000; --tw-ring-shadow: 0 0 #0000; --tw-shadow: 0 0 #0000; --tw-shadow-colored: 0 0 #0000; white-space: pre-wrap; color: rgb(36, 41, 47); font-family: -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, &quot;Noto Sans&quot;, Helvetica, Arial, sans-serif, &quot;Apple Color Emoji&quot;, &quot;Segoe UI Emoji&quot;; font-size: 14px; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(244, 246, 248);">：</span></div><ul style="box-sizing: border-box; border-width: 0px; border-style: solid; border-color: rgb(229, 231, 235); --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgb(59 130 246 / .5); --tw-ring-offset-shadow: 0 0 #0000; --tw-ring-shadow: 0 0 #0000; --tw-shadow: 0 0 #0000; --tw-shadow-colored: 0 0 #0000; list-style: disc; margin: 0px 0px 16px; padding: 0px 0px 0px 2em; color: rgb(36, 41, 47); font-family: -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, &quot;Noto Sans&quot;, Helvetica, Arial, sans-serif, &quot;Apple Color Emoji&quot;, &quot;Segoe UI Emoji&quot;; font-size: 14px; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(244, 246, 248);"><li style="box-sizing: border-box; border-width: 0px; border-style: solid; border-color: rgb(229, 231, 235); --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-pan-x: ; --tw-pan-y: ; --tw-pinch-zoom: ; --tw-scroll-snap-strictness: proximity; --tw-ordinal: ; --tw-slashed-zero: ; --tw-numeric-figure: ; --tw-numeric-spacing: ; --tw-numeric-fraction: ; --tw-ring-inset: ; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgb(59 130 246 / .5); --tw-ring-offset-shadow: 0 0 #0000; --tw-ring-shadow: 0 0 #0000; --tw-shadow: 0 0 #0000; --tw-shadow-colored: 0 0 #0000; --tw-blur: ; --tw-brightness: ; --tw-contrast: ; --tw-grayscale: ; --tw-hue-rotate: ; --tw-invert: ; --tw-saturate: ; --tw-sepia: ; --tw-drop-shadow: ; --tw-backdrop-blur: ; --tw-backdrop-brightness: ; --tw-backdrop-contrast: ; --tw-backdrop-grayscale: ; --tw-backdrop-hue-rotate: ; --tw-backdrop-invert: ; --tw-backdrop-opacity: ; --tw-backdrop-saturate: ; --tw-backdrop-sepia: ;"><div><span style="box-sizing: border-box; border-width: 0px; border-style: solid; border-color: rgb(229, 231, 235); --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgb(59 130 246 / .5); --tw-ring-offset-shadow: 0 0 #0000; --tw-ring-shadow: 0 0 #0000; --tw-shadow: 0 0 #0000; --tw-shadow-colored: 0 0 #0000; font-family: ui-monospace, SFMono-Regular, &quot;SF Mono&quot;, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-size: 11.9px; white-space: break-spaces; background-color: var(--color-neutral-muted); border-radius: 6px;">Anchor</span> 是UI元素相对于父容器的定位方式的设置。它定义了UI元素在其父容器中固定的相对位置或边缘。</div></li></ul><div style="box-sizing: border-box; border-width: 0px; border-style: solid; border-color: rgb(229, 231, 235); --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgb(59 130 246 / 0.5); --tw-ring-offset-shadow: 0 0 #0000; --tw-ring-shadow: 0 0 #0000; --tw-shadow: 0 0 #0000; --tw-shadow-colored: 0 0 #0000; margin: 0px 0px 16px; white-space: pre-wrap; color: rgb(36, 41, 47); font-family: -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, &quot;Noto Sans&quot;, Helvetica, Arial, sans-serif, &quot;Apple Color Emoji&quot;, &quot;Segoe UI Emoji&quot;; font-size: 14px; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(244, 246, 248);"><span style="box-sizing: border-box; border-width: 0px; border-style: solid; border-color: rgb(229, 231, 235); --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgb(59 130 246 / .5); --tw-ring-offset-shadow: 0 0 #0000; --tw-ring-shadow: 0 0 #0000; --tw-shadow: 0 0 #0000; --tw-shadow-colored: 0 0 #0000; white-space: pre-wrap; color: rgb(36, 41, 47); font-family: -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, &quot;Noto Sans&quot;, Helvetica, Arial, sans-serif, &quot;Apple Color Emoji&quot;, &quot;Segoe UI Emoji&quot;; font-size: 14px; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(244, 246, 248); font-weight: bold;">作用</span><span style="box-sizing: border-box; border-width: 0px; border-style: solid; border-color: rgb(229, 231, 235); --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgb(59 130 246 / 0.5); --tw-ring-offset-shadow: 0 0 #0000; --tw-ring-shadow: 0 0 #0000; --tw-shadow: 0 0 #0000; --tw-shadow-colored: 0 0 #0000; white-space: pre-wrap; color: rgb(36, 41, 47); font-family: -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, &quot;Noto Sans&quot;, Helvetica, Arial, sans-serif, &quot;Apple Color Emoji&quot;, &quot;Segoe UI Emoji&quot;; font-size: 14px; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(244, 246, 248);">：</span></div><ul style="box-sizing: border-box; border-width: 0px; border-style: solid; border-color: rgb(229, 231, 235); --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgb(59 130 246 / .5); --tw-ring-offset-shadow: 0 0 #0000; --tw-ring-shadow: 0 0 #0000; --tw-shadow: 0 0 #0000; --tw-shadow-colored: 0 0 #0000; list-style: disc; margin: 0px 0px 16px; padding: 0px 0px 0px 2em; color: rgb(36, 41, 47); font-family: -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, &quot;Noto Sans&quot;, Helvetica, Arial, sans-serif, &quot;Apple Color Emoji&quot;, &quot;Segoe UI Emoji&quot;; font-size: 14px; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(244, 246, 248);"><li style="box-sizing: border-box; border-width: 0px; border-style: solid; border-color: rgb(229, 231, 235); --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-pan-x: ; --tw-pan-y: ; --tw-pinch-zoom: ; --tw-scroll-snap-strictness: proximity; --tw-ordinal: ; --tw-slashed-zero: ; --tw-numeric-figure: ; --tw-numeric-spacing: ; --tw-numeric-fraction: ; --tw-ring-inset: ; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgb(59 130 246 / .5); --tw-ring-offset-shadow: 0 0 #0000; --tw-ring-shadow: 0 0 #0000; --tw-shadow: 0 0 #0000; --tw-shadow-colored: 0 0 #0000; --tw-blur: ; --tw-brightness: ; --tw-contrast: ; --tw-grayscale: ; --tw-hue-rotate: ; --tw-invert: ; --tw-saturate: ; --tw-sepia: ; --tw-drop-shadow: ; --tw-backdrop-blur: ; --tw-backdrop-brightness: ; --tw-backdrop-contrast: ; --tw-backdrop-grayscale: ; --tw-backdrop-hue-rotate: ; --tw-backdrop-invert: ; --tw-backdrop-opacity: ; --tw-backdrop-saturate: ; --tw-backdrop-sepia: ;"><div>控制UI元素的相对位置。当父容器的尺寸发生变化时，UI元素会根据其锚点调整位置。</div></li><li style="box-sizing: border-box; border-width: 0px; border-style: solid; border-color: rgb(229, 231, 235); --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-pan-x: ; --tw-pan-y: ; --tw-pinch-zoom: ; --tw-scroll-snap-strictness: proximity; --tw-ordinal: ; --tw-slashed-zero: ; --tw-numeric-figure: ; --tw-numeric-spacing: ; --tw-numeric-fraction: ; --tw-ring-inset: ; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgb(59 130 246 / .5); --tw-ring-offset-shadow: 0 0 #0000; --tw-ring-shadow: 0 0 #0000; --tw-shadow: 0 0 #0000; --tw-shadow-colored: 0 0 #0000; --tw-blur: ; --tw-brightness: ; --tw-contrast: ; --tw-grayscale: ; --tw-hue-rotate: ; --tw-invert: ; --tw-saturate: ; --tw-sepia: ; --tw-drop-shadow: ; --tw-backdrop-blur: ; --tw-backdrop-brightness: ; --tw-backdrop-contrast: ; --tw-backdrop-grayscale: ; --tw-backdrop-hue-rotate: ; --tw-backdrop-invert: ; --tw-backdrop-opacity: ; --tw-backdrop-saturate: ; --tw-backdrop-sepia: ; margin-top: 0.25em;"><div>有四个基本的锚点位置（左上、右上、左下、右下）以及它们的组合，用户可以将UI元素的锚点设置在这些位置或它们之间的任意位置。</div></li></ul><div style="box-sizing: border-box; border-width: 0px; border-style: solid; border-color: rgb(229, 231, 235); --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgb(59 130 246 / 0.5); --tw-ring-offset-shadow: 0 0 #0000; --tw-ring-shadow: 0 0 #0000; --tw-shadow: 0 0 #0000; --tw-shadow-colored: 0 0 #0000; margin: 0px 0px 16px; white-space: pre-wrap; color: rgb(36, 41, 47); font-family: -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, &quot;Noto Sans&quot;, Helvetica, Arial, sans-serif, &quot;Apple Color Emoji&quot;, &quot;Segoe UI Emoji&quot;; font-size: 14px; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(244, 246, 248);"><span style="box-sizing: border-box; border-width: 0px; border-style: solid; border-color: rgb(229, 231, 235); --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgb(59 130 246 / .5); --tw-ring-offset-shadow: 0 0 #0000; --tw-ring-shadow: 0 0 #0000; --tw-shadow: 0 0 #0000; --tw-shadow-colored: 0 0 #0000; white-space: pre-wrap; color: rgb(36, 41, 47); font-family: -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, &quot;Noto Sans&quot;, Helvetica, Arial, sans-serif, &quot;Apple Color Emoji&quot;, &quot;Segoe UI Emoji&quot;; font-size: 14px; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(244, 246, 248); font-weight: bold;">使用</span><span style="box-sizing: border-box; border-width: 0px; border-style: solid; border-color: rgb(229, 231, 235); --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgb(59 130 246 / 0.5); --tw-ring-offset-shadow: 0 0 #0000; --tw-ring-shadow: 0 0 #0000; --tw-shadow: 0 0 #0000; --tw-shadow-colored: 0 0 #0000; white-space: pre-wrap; color: rgb(36, 41, 47); font-family: -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, &quot;Noto Sans&quot;, Helvetica, Arial, sans-serif, &quot;Apple Color Emoji&quot;, &quot;Segoe UI Emoji&quot;; font-size: 14px; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(244, 246, 248);">：</span></div><ul style="box-sizing: border-box; border-width: 0px; border-style: solid; border-color: rgb(229, 231, 235); --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgb(59 130 246 / .5); --tw-ring-offset-shadow: 0 0 #0000; --tw-ring-shadow: 0 0 #0000; --tw-shadow: 0 0 #0000; --tw-shadow-colored: 0 0 #0000; list-style: disc; margin: 0px 0px 16px; padding: 0px 0px 0px 2em; color: rgb(36, 41, 47); font-family: -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, &quot;Noto Sans&quot;, Helvetica, Arial, sans-serif, &quot;Apple Color Emoji&quot;, &quot;Segoe UI Emoji&quot;; font-size: 14px; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(244, 246, 248);"><li style="box-sizing: border-box; border-width: 0px; border-style: solid; border-color: rgb(229, 231, 235); --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-pan-x: ; --tw-pan-y: ; --tw-pinch-zoom: ; --tw-scroll-snap-strictness: proximity; --tw-ordinal: ; --tw-slashed-zero: ; --tw-numeric-figure: ; --tw-numeric-spacing: ; --tw-numeric-fraction: ; --tw-ring-inset: ; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgb(59 130 246 / .5); --tw-ring-offset-shadow: 0 0 #0000; --tw-ring-shadow: 0 0 #0000; --tw-shadow: 0 0 #0000; --tw-shadow-colored: 0 0 #0000; --tw-blur: ; --tw-brightness: ; --tw-contrast: ; --tw-grayscale: ; --tw-hue-rotate: ; --tw-invert: ; --tw-saturate: ; --tw-sepia: ; --tw-drop-shadow: ; --tw-backdrop-blur: ; --tw-backdrop-brightness: ; --tw-backdrop-contrast: ; --tw-backdrop-grayscale: ; --tw-backdrop-hue-rotate: ; --tw-backdrop-invert: ; --tw-backdrop-opacity: ; --tw-backdrop-saturate: ; --tw-backdrop-sepia: ;"><div>通过<span style="box-sizing: border-box; border-width: 0px; border-style: solid; border-color: rgb(229, 231, 235); --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgb(59 130 246 / .5); --tw-ring-offset-shadow: 0 0 #0000; --tw-ring-shadow: 0 0 #0000; --tw-shadow: 0 0 #0000; --tw-shadow-colored: 0 0 #0000; font-family: ui-monospace, SFMono-Regular, &quot;SF Mono&quot;, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-size: 11.9px; white-space: break-spaces; background-color: var(--color-neutral-muted); border-radius: 6px;">RectTransform</span>组件的<span style="box-sizing: border-box; border-width: 0px; border-style: solid; border-color: rgb(229, 231, 235); --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgb(59 130 246 / .5); --tw-ring-offset-shadow: 0 0 #0000; --tw-ring-shadow: 0 0 #0000; --tw-shadow: 0 0 #0000; --tw-shadow-colored: 0 0 #0000; font-family: ui-monospace, SFMono-Regular, &quot;SF Mono&quot;, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-size: 11.9px; white-space: break-spaces; background-color: var(--color-neutral-muted); border-radius: 6px;">Anchor Min</span>和<span style="box-sizing: border-box; border-width: 0px; border-style: solid; border-color: rgb(229, 231, 235); --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgb(59 130 246 / .5); --tw-ring-offset-shadow: 0 0 #0000; --tw-ring-shadow: 0 0 #0000; --tw-shadow: 0 0 #0000; --tw-shadow-colored: 0 0 #0000; font-family: ui-monospace, SFMono-Regular, &quot;SF Mono&quot;, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-size: 11.9px; white-space: break-spaces; background-color: var(--color-neutral-muted); border-radius: 6px;">Anchor Max</span>属性来设置锚点的位置。</div></li><li style="box-sizing: border-box; border-width: 0px; border-style: solid; border-color: rgb(229, 231, 235); --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-pan-x: ; --tw-pan-y: ; --tw-pinch-zoom: ; --tw-scroll-snap-strictness: proximity; --tw-ordinal: ; --tw-slashed-zero: ; --tw-numeric-figure: ; --tw-numeric-spacing: ; --tw-numeric-fraction: ; --tw-ring-inset: ; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgb(59 130 246 / .5); --tw-ring-offset-shadow: 0 0 #0000; --tw-ring-shadow: 0 0 #0000; --tw-shadow: 0 0 #0000; --tw-shadow-colored: 0 0 #0000; --tw-blur: ; --tw-brightness: ; --tw-contrast: ; --tw-grayscale: ; --tw-hue-rotate: ; --tw-invert: ; --tw-saturate: ; --tw-sepia: ; --tw-drop-shadow: ; --tw-backdrop-blur: ; --tw-backdrop-brightness: ; --tw-backdrop-contrast: ; --tw-backdrop-grayscale: ; --tw-backdrop-hue-rotate: ; --tw-backdrop-invert: ; --tw-backdrop-opacity: ; --tw-backdrop-saturate: ; --tw-backdrop-sepia: ; margin-top: 0.25em;"><div>如果锚点设置为 <span style="box-sizing: border-box; border-width: 0px; border-style: solid; border-color: rgb(229, 231, 235); --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgb(59 130 246 / .5); --tw-ring-offset-shadow: 0 0 #0000; --tw-ring-shadow: 0 0 #0000; --tw-shadow: 0 0 #0000; --tw-shadow-colored: 0 0 #0000; font-family: ui-monospace, SFMono-Regular, &quot;SF Mono&quot;, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-size: 11.9px; white-space: break-spaces; background-color: var(--color-neutral-muted); border-radius: 6px;">(0, 0)</span>，则UI元素的左下角将对齐父容器的左下角。</div></li><li style="box-sizing: border-box; border-width: 0px; border-style: solid; border-color: rgb(229, 231, 235); --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-pan-x: ; --tw-pan-y: ; --tw-pinch-zoom: ; --tw-scroll-snap-strictness: proximity; --tw-ordinal: ; --tw-slashed-zero: ; --tw-numeric-figure: ; --tw-numeric-spacing: ; --tw-numeric-fraction: ; --tw-ring-inset: ; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgb(59 130 246 / .5); --tw-ring-offset-shadow: 0 0 #0000; --tw-ring-shadow: 0 0 #0000; --tw-shadow: 0 0 #0000; --tw-shadow-colored: 0 0 #0000; --tw-blur: ; --tw-brightness: ; --tw-contrast: ; --tw-grayscale: ; --tw-hue-rotate: ; --tw-invert: ; --tw-saturate: ; --tw-sepia: ; --tw-drop-shadow: ; --tw-backdrop-blur: ; --tw-backdrop-brightness: ; --tw-backdrop-contrast: ; --tw-backdrop-grayscale: ; --tw-backdrop-hue-rotate: ; --tw-backdrop-invert: ; --tw-backdrop-opacity: ; --tw-backdrop-saturate: ; --tw-backdrop-sepia: ; margin-top: 0.25em;"><div>如果锚点设置为 <span style="box-sizing: border-box; border-width: 0px; border-style: solid; border-color: rgb(229, 231, 235); --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgb(59 130 246 / .5); --tw-ring-offset-shadow: 0 0 #0000; --tw-ring-shadow: 0 0 #0000; --tw-shadow: 0 0 #0000; --tw-shadow-colored: 0 0 #0000; font-family: ui-monospace, SFMono-Regular, &quot;SF Mono&quot;, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-size: 11.9px; white-space: break-spaces; background-color: var(--color-neutral-muted); border-radius: 6px;">(1, 1)</span>，则UI元素的右上角将对齐父容器的右上角。</div></li></ul><div style="box-sizing: border-box; border-width: 0px; border-style: solid; border-color: rgb(229, 231, 235); --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgb(59 130 246 / 0.5); --tw-ring-offset-shadow: 0 0 #0000; --tw-ring-shadow: 0 0 #0000; --tw-shadow: 0 0 #0000; --tw-shadow-colored: 0 0 #0000; margin: 0px 0px 16px; white-space: pre-wrap; color: rgb(36, 41, 47); font-family: -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, &quot;Noto Sans&quot;, Helvetica, Arial, sans-serif, &quot;Apple Color Emoji&quot;, &quot;Segoe UI Emoji&quot;; font-size: 14px; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(244, 246, 248);"><span style="box-sizing: border-box; border-width: 0px; border-style: solid; border-color: rgb(229, 231, 235); --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgb(59 130 246 / .5); --tw-ring-offset-shadow: 0 0 #0000; --tw-ring-shadow: 0 0 #0000; --tw-shadow: 0 0 #0000; --tw-shadow-colored: 0 0 #0000; white-space: pre-wrap; color: rgb(36, 41, 47); font-family: -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, &quot;Noto Sans&quot;, Helvetica, Arial, sans-serif, &quot;Apple Color Emoji&quot;, &quot;Segoe UI Emoji&quot;; font-size: 14px; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(244, 246, 248); font-weight: bold;">示例</span><span style="box-sizing: border-box; border-width: 0px; border-style: solid; border-color: rgb(229, 231, 235); --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgb(59 130 246 / 0.5); --tw-ring-offset-shadow: 0 0 #0000; --tw-ring-shadow: 0 0 #0000; --tw-shadow: 0 0 #0000; --tw-shadow-colored: 0 0 #0000; white-space: pre-wrap; color: rgb(36, 41, 47); font-family: -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, &quot;Noto Sans&quot;, Helvetica, Arial, sans-serif, &quot;Apple Color Emoji&quot;, &quot;Segoe UI Emoji&quot;; font-size: 14px; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(244, 246, 248);">：</span></div><ul style="box-sizing: border-box; border-width: 0px; border-style: solid; border-color: rgb(229, 231, 235); --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgb(59 130 246 / .5); --tw-ring-offset-shadow: 0 0 #0000; --tw-ring-shadow: 0 0 #0000; --tw-shadow: 0 0 #0000; --tw-shadow-colored: 0 0 #0000; list-style: disc; margin: 0px 0px 16px; padding: 0px 0px 0px 2em; color: rgb(36, 41, 47); font-family: -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, &quot;Noto Sans&quot;, Helvetica, Arial, sans-serif, &quot;Apple Color Emoji&quot;, &quot;Segoe UI Emoji&quot;; font-size: 14px; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(244, 246, 248);"><li style="box-sizing: border-box; border-width: 0px; border-style: solid; border-color: rgb(229, 231, 235); --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-pan-x: ; --tw-pan-y: ; --tw-pinch-zoom: ; --tw-scroll-snap-strictness: proximity; --tw-ordinal: ; --tw-slashed-zero: ; --tw-numeric-figure: ; --tw-numeric-spacing: ; --tw-numeric-fraction: ; --tw-ring-inset: ; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgb(59 130 246 / .5); --tw-ring-offset-shadow: 0 0 #0000; --tw-ring-shadow: 0 0 #0000; --tw-shadow: 0 0 #0000; --tw-shadow-colored: 0 0 #0000; --tw-blur: ; --tw-brightness: ; --tw-contrast: ; --tw-grayscale: ; --tw-hue-rotate: ; --tw-invert: ; --tw-saturate: ; --tw-sepia: ; --tw-drop-shadow: ; --tw-backdrop-blur: ; --tw-backdrop-brightness: ; --tw-backdrop-contrast: ; --tw-backdrop-grayscale: ; --tw-backdrop-hue-rotate: ; --tw-backdrop-invert: ; --tw-backdrop-opacity: ; --tw-backdrop-saturate: ; --tw-backdrop-sepia: ;"><div>如果将锚点设置为 <span style="box-sizing: border-box; border-width: 0px; border-style: solid; border-color: rgb(229, 231, 235); --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgb(59 130 246 / .5); --tw-ring-offset-shadow: 0 0 #0000; --tw-ring-shadow: 0 0 #0000; --tw-shadow: 0 0 #0000; --tw-shadow-colored: 0 0 #0000; font-family: ui-monospace, SFMono-Regular, &quot;SF Mono&quot;, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-size: 11.9px; white-space: break-spaces; background-color: var(--color-neutral-muted); border-radius: 6px;">(0.5, 0.5)</span>，则UI元素的中心点会固定在父容器的中心。</div></li><li style="box-sizing: border-box; border-width: 0px; border-style: solid; border-color: rgb(229, 231, 235); --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-pan-x: ; --tw-pan-y: ; --tw-pinch-zoom: ; --tw-scroll-snap-strictness: proximity; --tw-ordinal: ; --tw-slashed-zero: ; --tw-numeric-figure: ; --tw-numeric-spacing: ; --tw-numeric-fraction: ; --tw-ring-inset: ; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgb(59 130 246 / .5); --tw-ring-offset-shadow: 0 0 #0000; --tw-ring-shadow: 0 0 #0000; --tw-shadow: 0 0 #0000; --tw-shadow-colored: 0 0 #0000; --tw-blur: ; --tw-brightness: ; --tw-contrast: ; --tw-grayscale: ; --tw-hue-rotate: ; --tw-invert: ; --tw-saturate: ; --tw-sepia: ; --tw-drop-shadow: ; --tw-backdrop-blur: ; --tw-backdrop-brightness: ; --tw-backdrop-contrast: ; --tw-backdrop-grayscale: ; --tw-backdrop-hue-rotate: ; --tw-backdrop-invert: ; --tw-backdrop-opacity: ; --tw-backdrop-saturate: ; --tw-backdrop-sepia: ; margin-top: 0.25em;"><div>如果将锚点设置为 <span style="box-sizing: border-box; border-width: 0px; border-style: solid; border-color: rgb(229, 231, 235); --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgb(59 130 246 / .5); --tw-ring-offset-shadow: 0 0 #0000; --tw-ring-shadow: 0 0 #0000; --tw-shadow: 0 0 #0000; --tw-shadow-colored: 0 0 #0000; font-family: ui-monospace, SFMono-Regular, &quot;SF Mono&quot;, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-size: 11.9px; white-space: break-spaces; background-color: var(--color-neutral-muted); border-radius: 6px;">(0, 1)</span>，则UI元素的上边缘会对齐到父容器的上边缘。</div></li></ul><h3 style="box-sizing: border-box; border-width: 0px; border-style: solid; border-color: rgb(229, 231, 235); --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgb(59 130 246 / .5); --tw-ring-offset-shadow: 0 0 #0000; --tw-ring-shadow: 0 0 #0000; --tw-shadow: 0 0 #0000; --tw-shadow-colored: 0 0 #0000; font-size: 1.25em; margin: 24px 0px 16px; line-height: 1.25; color: rgb(36, 41, 47); font-family: -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, &quot;Noto Sans&quot;, Helvetica, Arial, sans-serif, &quot;Apple Color Emoji&quot;, &quot;Segoe UI Emoji&quot;; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(244, 246, 248);"><span style="box-sizing: border-box; border-width: 0px; border-style: solid; border-color: rgb(229, 231, 235); --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgb(59 130 246 / .5); --tw-ring-offset-shadow: 0 0 #0000; --tw-ring-shadow: 0 0 #0000; --tw-shadow: 0 0 #0000; --tw-shadow-colored: 0 0 #0000; font-size: 1.25em; line-height: 1.25; color: rgb(36, 41, 47); font-family: -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, &quot;Noto Sans&quot;, Helvetica, Arial, sans-serif, &quot;Apple Color Emoji&quot;, &quot;Segoe UI Emoji&quot;; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(244, 246, 248);">2. Pivot（支点）</span></h3><div style="box-sizing: border-box; border-width: 0px; border-style: solid; border-color: rgb(229, 231, 235); --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgb(59 130 246 / 0.5); --tw-ring-offset-shadow: 0 0 #0000; --tw-ring-shadow: 0 0 #0000; --tw-shadow: 0 0 #0000; --tw-shadow-colored: 0 0 #0000; margin: 0px 0px 16px; white-space: pre-wrap; color: rgb(36, 41, 47); font-family: -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, &quot;Noto Sans&quot;, Helvetica, Arial, sans-serif, &quot;Apple Color Emoji&quot;, &quot;Segoe UI Emoji&quot;; font-size: 14px; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(244, 246, 248);"><span style="box-sizing: border-box; border-width: 0px; border-style: solid; border-color: rgb(229, 231, 235); --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgb(59 130 246 / .5); --tw-ring-offset-shadow: 0 0 #0000; --tw-ring-shadow: 0 0 #0000; --tw-shadow: 0 0 #0000; --tw-shadow-colored: 0 0 #0000; white-space: pre-wrap; color: rgb(36, 41, 47); font-family: -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, &quot;Noto Sans&quot;, Helvetica, Arial, sans-serif, &quot;Apple Color Emoji&quot;, &quot;Segoe UI Emoji&quot;; font-size: 14px; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(244, 246, 248); font-weight: bold;">定义</span><span style="box-sizing: border-box; border-width: 0px; border-style: solid; border-color: rgb(229, 231, 235); --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgb(59 130 246 / 0.5); --tw-ring-offset-shadow: 0 0 #0000; --tw-ring-shadow: 0 0 #0000; --tw-shadow: 0 0 #0000; --tw-shadow-colored: 0 0 #0000; white-space: pre-wrap; color: rgb(36, 41, 47); font-family: -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, &quot;Noto Sans&quot;, Helvetica, Arial, sans-serif, &quot;Apple Color Emoji&quot;, &quot;Segoe UI Emoji&quot;; font-size: 14px; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(244, 246, 248);">：</span></div><ul style="box-sizing: border-box; border-width: 0px; border-style: solid; border-color: rgb(229, 231, 235); --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgb(59 130 246 / .5); --tw-ring-offset-shadow: 0 0 #0000; --tw-ring-shadow: 0 0 #0000; --tw-shadow: 0 0 #0000; --tw-shadow-colored: 0 0 #0000; list-style: disc; margin: 0px 0px 16px; padding: 0px 0px 0px 2em; color: rgb(36, 41, 47); font-family: -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, &quot;Noto Sans&quot;, Helvetica, Arial, sans-serif, &quot;Apple Color Emoji&quot;, &quot;Segoe UI Emoji&quot;; font-size: 14px; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(244, 246, 248);"><li style="box-sizing: border-box; border-width: 0px; border-style: solid; border-color: rgb(229, 231, 235); --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-pan-x: ; --tw-pan-y: ; --tw-pinch-zoom: ; --tw-scroll-snap-strictness: proximity; --tw-ordinal: ; --tw-slashed-zero: ; --tw-numeric-figure: ; --tw-numeric-spacing: ; --tw-numeric-fraction: ; --tw-ring-inset: ; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgb(59 130 246 / .5); --tw-ring-offset-shadow: 0 0 #0000; --tw-ring-shadow: 0 0 #0000; --tw-shadow: 0 0 #0000; --tw-shadow-colored: 0 0 #0000; --tw-blur: ; --tw-brightness: ; --tw-contrast: ; --tw-grayscale: ; --tw-hue-rotate: ; --tw-invert: ; --tw-saturate: ; --tw-sepia: ; --tw-drop-shadow: ; --tw-backdrop-blur: ; --tw-backdrop-brightness: ; --tw-backdrop-contrast: ; --tw-backdrop-grayscale: ; --tw-backdrop-hue-rotate: ; --tw-backdrop-invert: ; --tw-backdrop-opacity: ; --tw-backdrop-saturate: ; --tw-backdrop-sepia: ;"><div><span style="box-sizing: border-box; border-width: 0px; border-style: solid; border-color: rgb(229, 231, 235); --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgb(59 130 246 / .5); --tw-ring-offset-shadow: 0 0 #0000; --tw-ring-shadow: 0 0 #0000; --tw-shadow: 0 0 #0000; --tw-shadow-colored: 0 0 #0000; font-family: ui-monospace, SFMono-Regular, &quot;SF Mono&quot;, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-size: 11.9px; white-space: break-spaces; background-color: var(--color-neutral-muted); border-radius: 6px;">Pivot</span> 是UI元素自身的定位点，定义了UI元素内部的一个相对位置，用于旋转和缩放的参考点。</div></li></ul><div style="box-sizing: border-box; border-width: 0px; border-style: solid; border-color: rgb(229, 231, 235); --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgb(59 130 246 / 0.5); --tw-ring-offset-shadow: 0 0 #0000; --tw-ring-shadow: 0 0 #0000; --tw-shadow: 0 0 #0000; --tw-shadow-colored: 0 0 #0000; margin: 0px 0px 16px; white-space: pre-wrap; color: rgb(36, 41, 47); font-family: -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, &quot;Noto Sans&quot;, Helvetica, Arial, sans-serif, &quot;Apple Color Emoji&quot;, &quot;Segoe UI Emoji&quot;; font-size: 14px; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(244, 246, 248);"><span style="box-sizing: border-box; border-width: 0px; border-style: solid; border-color: rgb(229, 231, 235); --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgb(59 130 246 / .5); --tw-ring-offset-shadow: 0 0 #0000; --tw-ring-shadow: 0 0 #0000; --tw-shadow: 0 0 #0000; --tw-shadow-colored: 0 0 #0000; white-space: pre-wrap; color: rgb(36, 41, 47); font-family: -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, &quot;Noto Sans&quot;, Helvetica, Arial, sans-serif, &quot;Apple Color Emoji&quot;, &quot;Segoe UI Emoji&quot;; font-size: 14px; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(244, 246, 248); font-weight: bold;">作用</span><span style="box-sizing: border-box; border-width: 0px; border-style: solid; border-color: rgb(229, 231, 235); --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgb(59 130 246 / 0.5); --tw-ring-offset-shadow: 0 0 #0000; --tw-ring-shadow: 0 0 #0000; --tw-shadow: 0 0 #0000; --tw-shadow-colored: 0 0 #0000; white-space: pre-wrap; color: rgb(36, 41, 47); font-family: -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, &quot;Noto Sans&quot;, Helvetica, Arial, sans-serif, &quot;Apple Color Emoji&quot;, &quot;Segoe UI Emoji&quot;; font-size: 14px; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(244, 246, 248);">：</span></div><ul style="box-sizing: border-box; border-width: 0px; border-style: solid; border-color: rgb(229, 231, 235); --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgb(59 130 246 / .5); --tw-ring-offset-shadow: 0 0 #0000; --tw-ring-shadow: 0 0 #0000; --tw-shadow: 0 0 #0000; --tw-shadow-colored: 0 0 #0000; list-style: disc; margin: 0px 0px 16px; padding: 0px 0px 0px 2em; color: rgb(36, 41, 47); font-family: -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, &quot;Noto Sans&quot;, Helvetica, Arial, sans-serif, &quot;Apple Color Emoji&quot;, &quot;Segoe UI Emoji&quot;; font-size: 14px; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(244, 246, 248);"><li style="box-sizing: border-box; border-width: 0px; border-style: solid; border-color: rgb(229, 231, 235); --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-pan-x: ; --tw-pan-y: ; --tw-pinch-zoom: ; --tw-scroll-snap-strictness: proximity; --tw-ordinal: ; --tw-slashed-zero: ; --tw-numeric-figure: ; --tw-numeric-spacing: ; --tw-numeric-fraction: ; --tw-ring-inset: ; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgb(59 130 246 / .5); --tw-ring-offset-shadow: 0 0 #0000; --tw-ring-shadow: 0 0 #0000; --tw-shadow: 0 0 #0000; --tw-shadow-colored: 0 0 #0000; --tw-blur: ; --tw-brightness: ; --tw-contrast: ; --tw-grayscale: ; --tw-hue-rotate: ; --tw-invert: ; --tw-saturate: ; --tw-sepia: ; --tw-drop-shadow: ; --tw-backdrop-blur: ; --tw-backdrop-brightness: ; --tw-backdrop-contrast: ; --tw-backdrop-grayscale: ; --tw-backdrop-hue-rotate: ; --tw-backdrop-invert: ; --tw-backdrop-opacity: ; --tw-backdrop-saturate: ; --tw-backdrop-sepia: ;"><div>控制UI元素的旋转和缩放的中心点。<span style="box-sizing: border-box; border-width: 0px; border-style: solid; border-color: rgb(229, 231, 235); --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgb(59 130 246 / .5); --tw-ring-offset-shadow: 0 0 #0000; --tw-ring-shadow: 0 0 #0000; --tw-shadow: 0 0 #0000; --tw-shadow-colored: 0 0 #0000; font-family: ui-monospace, SFMono-Regular, &quot;SF Mono&quot;, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-size: 11.9px; white-space: break-spaces; background-color: var(--color-neutral-muted); border-radius: 6px;">Pivot</span> 的位置决定了这些变换是相对于UI元素的哪个点进行的。</div></li><li style="box-sizing: border-box; border-width: 0px; border-style: solid; border-color: rgb(229, 231, 235); --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-pan-x: ; --tw-pan-y: ; --tw-pinch-zoom: ; --tw-scroll-snap-strictness: proximity; --tw-ordinal: ; --tw-slashed-zero: ; --tw-numeric-figure: ; --tw-numeric-spacing: ; --tw-numeric-fraction: ; --tw-ring-inset: ; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgb(59 130 246 / .5); --tw-ring-offset-shadow: 0 0 #0000; --tw-ring-shadow: 0 0 #0000; --tw-shadow: 0 0 #0000; --tw-shadow-colored: 0 0 #0000; --tw-blur: ; --tw-brightness: ; --tw-contrast: ; --tw-grayscale: ; --tw-hue-rotate: ; --tw-invert: ; --tw-saturate: ; --tw-sepia: ; --tw-drop-shadow: ; --tw-backdrop-blur: ; --tw-backdrop-brightness: ; --tw-backdrop-contrast: ; --tw-backdrop-grayscale: ; --tw-backdrop-hue-rotate: ; --tw-backdrop-invert: ; --tw-backdrop-opacity: ; --tw-backdrop-saturate: ; --tw-backdrop-sepia: ; margin-top: 0.25em;"><div>不影响UI元素在父容器中的位置，只影响UI元素自身的变换。</div></li></ul><div style="box-sizing: border-box; border-width: 0px; border-style: solid; border-color: rgb(229, 231, 235); --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgb(59 130 246 / 0.5); --tw-ring-offset-shadow: 0 0 #0000; --tw-ring-shadow: 0 0 #0000; --tw-shadow: 0 0 #0000; --tw-shadow-colored: 0 0 #0000; margin: 0px 0px 16px; white-space: pre-wrap; color: rgb(36, 41, 47); font-family: -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, &quot;Noto Sans&quot;, Helvetica, Arial, sans-serif, &quot;Apple Color Emoji&quot;, &quot;Segoe UI Emoji&quot;; font-size: 14px; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(244, 246, 248);"><span style="box-sizing: border-box; border-width: 0px; border-style: solid; border-color: rgb(229, 231, 235); --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgb(59 130 246 / .5); --tw-ring-offset-shadow: 0 0 #0000; --tw-ring-shadow: 0 0 #0000; --tw-shadow: 0 0 #0000; --tw-shadow-colored: 0 0 #0000; white-space: pre-wrap; color: rgb(36, 41, 47); font-family: -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, &quot;Noto Sans&quot;, Helvetica, Arial, sans-serif, &quot;Apple Color Emoji&quot;, &quot;Segoe UI Emoji&quot;; font-size: 14px; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(244, 246, 248); font-weight: bold;">使用</span><span style="box-sizing: border-box; border-width: 0px; border-style: solid; border-color: rgb(229, 231, 235); --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgb(59 130 246 / 0.5); --tw-ring-offset-shadow: 0 0 #0000; --tw-ring-shadow: 0 0 #0000; --tw-shadow: 0 0 #0000; --tw-shadow-colored: 0 0 #0000; white-space: pre-wrap; color: rgb(36, 41, 47); font-family: -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, &quot;Noto Sans&quot;, Helvetica, Arial, sans-serif, &quot;Apple Color Emoji&quot;, &quot;Segoe UI Emoji&quot;; font-size: 14px; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(244, 246, 248);">：</span></div><ul style="box-sizing: border-box; border-width: 0px; border-style: solid; border-color: rgb(229, 231, 235); --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgb(59 130 246 / .5); --tw-ring-offset-shadow: 0 0 #0000; --tw-ring-shadow: 0 0 #0000; --tw-shadow: 0 0 #0000; --tw-shadow-colored: 0 0 #0000; list-style: disc; margin: 0px 0px 16px; padding: 0px 0px 0px 2em; color: rgb(36, 41, 47); font-family: -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, &quot;Noto Sans&quot;, Helvetica, Arial, sans-serif, &quot;Apple Color Emoji&quot;, &quot;Segoe UI Emoji&quot;; font-size: 14px; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(244, 246, 248);"><li style="box-sizing: border-box; border-width: 0px; border-style: solid; border-color: rgb(229, 231, 235); --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-pan-x: ; --tw-pan-y: ; --tw-pinch-zoom: ; --tw-scroll-snap-strictness: proximity; --tw-ordinal: ; --tw-slashed-zero: ; --tw-numeric-figure: ; --tw-numeric-spacing: ; --tw-numeric-fraction: ; --tw-ring-inset: ; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgb(59 130 246 / .5); --tw-ring-offset-shadow: 0 0 #0000; --tw-ring-shadow: 0 0 #0000; --tw-shadow: 0 0 #0000; --tw-shadow-colored: 0 0 #0000; --tw-blur: ; --tw-brightness: ; --tw-contrast: ; --tw-grayscale: ; --tw-hue-rotate: ; --tw-invert: ; --tw-saturate: ; --tw-sepia: ; --tw-drop-shadow: ; --tw-backdrop-blur: ; --tw-backdrop-brightness: ; --tw-backdrop-contrast: ; --tw-backdrop-grayscale: ; --tw-backdrop-hue-rotate: ; --tw-backdrop-invert: ; --tw-backdrop-opacity: ; --tw-backdrop-saturate: ; --tw-backdrop-sepia: ;"><div>通过<span style="box-sizing: border-box; border-width: 0px; border-style: solid; border-color: rgb(229, 231, 235); --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgb(59 130 246 / .5); --tw-ring-offset-shadow: 0 0 #0000; --tw-ring-shadow: 0 0 #0000; --tw-shadow: 0 0 #0000; --tw-shadow-colored: 0 0 #0000; font-family: ui-monospace, SFMono-Regular, &quot;SF Mono&quot;, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-size: 11.9px; white-space: break-spaces; background-color: var(--color-neutral-muted); border-radius: 6px;">RectTransform</span>组件的<span style="box-sizing: border-box; border-width: 0px; border-style: solid; border-color: rgb(229, 231, 235); --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgb(59 130 246 / .5); --tw-ring-offset-shadow: 0 0 #0000; --tw-ring-shadow: 0 0 #0000; --tw-shadow: 0 0 #0000; --tw-shadow-colored: 0 0 #0000; font-family: ui-monospace, SFMono-Regular, &quot;SF Mono&quot;, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-size: 11.9px; white-space: break-spaces; background-color: var(--color-neutral-muted); border-radius: 6px;">Pivot</span>属性来设置支点的位置，范围在 <span style="box-sizing: border-box; border-width: 0px; border-style: solid; border-color: rgb(229, 231, 235); --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgb(59 130 246 / .5); --tw-ring-offset-shadow: 0 0 #0000; --tw-ring-shadow: 0 0 #0000; --tw-shadow: 0 0 #0000; --tw-shadow-colored: 0 0 #0000; font-family: ui-monospace, SFMono-Regular, &quot;SF Mono&quot;, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-size: 11.9px; white-space: break-spaces; background-color: var(--color-neutral-muted); border-radius: 6px;">(0, 0)</span> 到 <span style="box-sizing: border-box; border-width: 0px; border-style: solid; border-color: rgb(229, 231, 235); --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgb(59 130 246 / .5); --tw-ring-offset-shadow: 0 0 #0000; --tw-ring-shadow: 0 0 #0000; --tw-shadow: 0 0 #0000; --tw-shadow-colored: 0 0 #0000; font-family: ui-monospace, SFMono-Regular, &quot;SF Mono&quot;, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-size: 11.9px; white-space: break-spaces; background-color: var(--color-neutral-muted); border-radius: 6px;">(1, 1)</span> 之间。</div></li><li style="box-sizing: border-box; border-width: 0px; border-style: solid; border-color: rgb(229, 231, 235); --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-pan-x: ; --tw-pan-y: ; --tw-pinch-zoom: ; --tw-scroll-snap-strictness: proximity; --tw-ordinal: ; --tw-slashed-zero: ; --tw-numeric-figure: ; --tw-numeric-spacing: ; --tw-numeric-fraction: ; --tw-ring-inset: ; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgb(59 130 246 / .5); --tw-ring-offset-shadow: 0 0 #0000; --tw-ring-shadow: 0 0 #0000; --tw-shadow: 0 0 #0000; --tw-shadow-colored: 0 0 #0000; --tw-blur: ; --tw-brightness: ; --tw-contrast: ; --tw-grayscale: ; --tw-hue-rotate: ; --tw-invert: ; --tw-saturate: ; --tw-sepia: ; --tw-drop-shadow: ; --tw-backdrop-blur: ; --tw-backdrop-brightness: ; --tw-backdrop-contrast: ; --tw-backdrop-grayscale: ; --tw-backdrop-hue-rotate: ; --tw-backdrop-invert: ; --tw-backdrop-opacity: ; --tw-backdrop-saturate: ; --tw-backdrop-sepia: ; margin-top: 0.25em;"><div><span style="box-sizing: border-box; border-width: 0px; border-style: solid; border-color: rgb(229, 231, 235); --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgb(59 130 246 / .5); --tw-ring-offset-shadow: 0 0 #0000; --tw-ring-shadow: 0 0 #0000; --tw-shadow: 0 0 #0000; --tw-shadow-colored: 0 0 #0000; font-family: ui-monospace, SFMono-Regular, &quot;SF Mono&quot;, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-size: 11.9px; white-space: break-spaces; background-color: var(--color-neutral-muted); border-radius: 6px;">Pivot</span> 的值为 <span style="box-sizing: border-box; border-width: 0px; border-style: solid; border-color: rgb(229, 231, 235); --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgb(59 130 246 / .5); --tw-ring-offset-shadow: 0 0 #0000; --tw-ring-shadow: 0 0 #0000; --tw-shadow: 0 0 #0000; --tw-shadow-colored: 0 0 #0000; font-family: ui-monospace, SFMono-Regular, &quot;SF Mono&quot;, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-size: 11.9px; white-space: break-spaces; background-color: var(--color-neutral-muted); border-radius: 6px;">(0.5, 0.5)</span> 时，表示UI元素的中心点为支点。</div></li><li style="box-sizing: border-box; border-width: 0px; border-style: solid; border-color: rgb(229, 231, 235); --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-pan-x: ; --tw-pan-y: ; --tw-pinch-zoom: ; --tw-scroll-snap-strictness: proximity; --tw-ordinal: ; --tw-slashed-zero: ; --tw-numeric-figure: ; --tw-numeric-spacing: ; --tw-numeric-fraction: ; --tw-ring-inset: ; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgb(59 130 246 / .5); --tw-ring-offset-shadow: 0 0 #0000; --tw-ring-shadow: 0 0 #0000; --tw-shadow: 0 0 #0000; --tw-shadow-colored: 0 0 #0000; --tw-blur: ; --tw-brightness: ; --tw-contrast: ; --tw-grayscale: ; --tw-hue-rotate: ; --tw-invert: ; --tw-saturate: ; --tw-sepia: ; --tw-drop-shadow: ; --tw-backdrop-blur: ; --tw-backdrop-brightness: ; --tw-backdrop-contrast: ; --tw-backdrop-grayscale: ; --tw-backdrop-hue-rotate: ; --tw-backdrop-invert: ; --tw-backdrop-opacity: ; --tw-backdrop-saturate: ; --tw-backdrop-sepia: ; margin-top: 0.25em;"><div>其他值如 <span style="box-sizing: border-box; border-width: 0px; border-style: solid; border-color: rgb(229, 231, 235); --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgb(59 130 246 / .5); --tw-ring-offset-shadow: 0 0 #0000; --tw-ring-shadow: 0 0 #0000; --tw-shadow: 0 0 #0000; --tw-shadow-colored: 0 0 #0000; font-family: ui-monospace, SFMono-Regular, &quot;SF Mono&quot;, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-size: 11.9px; white-space: break-spaces; background-color: var(--color-neutral-muted); border-radius: 6px;">(0, 0)</span> 表示UI元素的左下角为支点，而 <span style="box-sizing: border-box; border-width: 0px; border-style: solid; border-color: rgb(229, 231, 235); --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgb(59 130 246 / .5); --tw-ring-offset-shadow: 0 0 #0000; --tw-ring-shadow: 0 0 #0000; --tw-shadow: 0 0 #0000; --tw-shadow-colored: 0 0 #0000; font-family: ui-monospace, SFMono-Regular, &quot;SF Mono&quot;, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-size: 11.9px; white-space: break-spaces; background-color: var(--color-neutral-muted); border-radius: 6px;">(1, 1)</span> 表示右上角为支点。</div></li></ul><div style="box-sizing: border-box; border-width: 0px; border-style: solid; border-color: rgb(229, 231, 235); --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgb(59 130 246 / 0.5); --tw-ring-offset-shadow: 0 0 #0000; --tw-ring-shadow: 0 0 #0000; --tw-shadow: 0 0 #0000; --tw-shadow-colored: 0 0 #0000; margin: 0px 0px 16px; white-space: pre-wrap; color: rgb(36, 41, 47); font-family: -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, &quot;Noto Sans&quot;, Helvetica, Arial, sans-serif, &quot;Apple Color Emoji&quot;, &quot;Segoe UI Emoji&quot;; font-size: 14px; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(244, 246, 248);"><span style="box-sizing: border-box; border-width: 0px; border-style: solid; border-color: rgb(229, 231, 235); --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgb(59 130 246 / .5); --tw-ring-offset-shadow: 0 0 #0000; --tw-ring-shadow: 0 0 #0000; --tw-shadow: 0 0 #0000; --tw-shadow-colored: 0 0 #0000; white-space: pre-wrap; color: rgb(36, 41, 47); font-family: -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, &quot;Noto Sans&quot;, Helvetica, Arial, sans-serif, &quot;Apple Color Emoji&quot;, &quot;Segoe UI Emoji&quot;; font-size: 14px; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(244, 246, 248); font-weight: bold;">示例</span><span style="box-sizing: border-box; border-width: 0px; border-style: solid; border-color: rgb(229, 231, 235); --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgb(59 130 246 / 0.5); --tw-ring-offset-shadow: 0 0 #0000; --tw-ring-shadow: 0 0 #0000; --tw-shadow: 0 0 #0000; --tw-shadow-colored: 0 0 #0000; white-space: pre-wrap; color: rgb(36, 41, 47); font-family: -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, &quot;Noto Sans&quot;, Helvetica, Arial, sans-serif, &quot;Apple Color Emoji&quot;, &quot;Segoe UI Emoji&quot;; font-size: 14px; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(244, 246, 248);">：</span></div><ul style="box-sizing: border-box; border-width: 0px; border-style: solid; border-color: rgb(229, 231, 235); --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgb(59 130 246 / .5); --tw-ring-offset-shadow: 0 0 #0000; --tw-ring-shadow: 0 0 #0000; --tw-shadow: 0 0 #0000; --tw-shadow-colored: 0 0 #0000; list-style: disc; margin: 0px 0px 16px; padding: 0px 0px 0px 2em; color: rgb(36, 41, 47); font-family: -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, &quot;Noto Sans&quot;, Helvetica, Arial, sans-serif, &quot;Apple Color Emoji&quot;, &quot;Segoe UI Emoji&quot;; font-size: 14px; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(244, 246, 248);"><li style="box-sizing: border-box; border-width: 0px; border-style: solid; border-color: rgb(229, 231, 235); --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-pan-x: ; --tw-pan-y: ; --tw-pinch-zoom: ; --tw-scroll-snap-strictness: proximity; --tw-ordinal: ; --tw-slashed-zero: ; --tw-numeric-figure: ; --tw-numeric-spacing: ; --tw-numeric-fraction: ; --tw-ring-inset: ; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgb(59 130 246 / .5); --tw-ring-offset-shadow: 0 0 #0000; --tw-ring-shadow: 0 0 #0000; --tw-shadow: 0 0 #0000; --tw-shadow-colored: 0 0 #0000; --tw-blur: ; --tw-brightness: ; --tw-contrast: ; --tw-grayscale: ; --tw-hue-rotate: ; --tw-invert: ; --tw-saturate: ; --tw-sepia: ; --tw-drop-shadow: ; --tw-backdrop-blur: ; --tw-backdrop-brightness: ; --tw-backdrop-contrast: ; --tw-backdrop-grayscale: ; --tw-backdrop-hue-rotate: ; --tw-backdrop-invert: ; --tw-backdrop-opacity: ; --tw-backdrop-saturate: ; --tw-backdrop-sepia: ;"><div>如果你将<span style="box-sizing: border-box; border-width: 0px; border-style: solid; border-color: rgb(229, 231, 235); --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgb(59 130 246 / .5); --tw-ring-offset-shadow: 0 0 #0000; --tw-ring-shadow: 0 0 #0000; --tw-shadow: 0 0 #0000; --tw-shadow-colored: 0 0 #0000; font-family: ui-monospace, SFMono-Regular, &quot;SF Mono&quot;, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-size: 11.9px; white-space: break-spaces; background-color: var(--color-neutral-muted); border-radius: 6px;">Pivot</span>设置为 <span style="box-sizing: border-box; border-width: 0px; border-style: solid; border-color: rgb(229, 231, 235); --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgb(59 130 246 / .5); --tw-ring-offset-shadow: 0 0 #0000; --tw-ring-shadow: 0 0 #0000; --tw-shadow: 0 0 #0000; --tw-shadow-colored: 0 0 #0000; font-family: ui-monospace, SFMono-Regular, &quot;SF Mono&quot;, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-size: 11.9px; white-space: break-spaces; background-color: var(--color-neutral-muted); border-radius: 6px;">(0, 0)</span>，当你对UI元素进行旋转或缩放时，这些操作会围绕元素的左下角进行。</div></li><li style="box-sizing: border-box; border-width: 0px; border-style: solid; border-color: rgb(229, 231, 235); --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-pan-x: ; --tw-pan-y: ; --tw-pinch-zoom: ; --tw-scroll-snap-strictness: proximity; --tw-ordinal: ; --tw-slashed-zero: ; --tw-numeric-figure: ; --tw-numeric-spacing: ; --tw-numeric-fraction: ; --tw-ring-inset: ; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgb(59 130 246 / .5); --tw-ring-offset-shadow: 0 0 #0000; --tw-ring-shadow: 0 0 #0000; --tw-shadow: 0 0 #0000; --tw-shadow-colored: 0 0 #0000; --tw-blur: ; --tw-brightness: ; --tw-contrast: ; --tw-grayscale: ; --tw-hue-rotate: ; --tw-invert: ; --tw-saturate: ; --tw-sepia: ; --tw-drop-shadow: ; --tw-backdrop-blur: ; --tw-backdrop-brightness: ; --tw-backdrop-contrast: ; --tw-backdrop-grayscale: ; --tw-backdrop-hue-rotate: ; --tw-backdrop-invert: ; --tw-backdrop-opacity: ; --tw-backdrop-saturate: ; --tw-backdrop-sepia: ; margin-top: 0.25em;"><div>如果将<span style="box-sizing: border-box; border-width: 0px; border-style: solid; border-color: rgb(229, 231, 235); --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgb(59 130 246 / .5); --tw-ring-offset-shadow: 0 0 #0000; --tw-ring-shadow: 0 0 #0000; --tw-shadow: 0 0 #0000; --tw-shadow-colored: 0 0 #0000; font-family: ui-monospace, SFMono-Regular, &quot;SF Mono&quot;, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-size: 11.9px; white-space: break-spaces; background-color: var(--color-neutral-muted); border-radius: 6px;">Pivot</span>设置为 <span style="box-sizing: border-box; border-width: 0px; border-style: solid; border-color: rgb(229, 231, 235); --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgb(59 130 246 / .5); --tw-ring-offset-shadow: 0 0 #0000; --tw-ring-shadow: 0 0 #0000; --tw-shadow: 0 0 #0000; --tw-shadow-colored: 0 0 #0000; font-family: ui-monospace, SFMono-Regular, &quot;SF Mono&quot;, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-size: 11.9px; white-space: break-spaces; background-color: var(--color-neutral-muted); border-radius: 6px;">(1, 1)</span>，则变换将围绕元素的右上角进行。</div></li></ul><h3 style="box-sizing: border-box; border-width: 0px; border-style: solid; border-color: rgb(229, 231, 235); --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgb(59 130 246 / .5); --tw-ring-offset-shadow: 0 0 #0000; --tw-ring-shadow: 0 0 #0000; --tw-shadow: 0 0 #0000; --tw-shadow-colored: 0 0 #0000; font-size: 1.25em; margin: 24px 0px 16px; line-height: 1.25; color: rgb(36, 41, 47); font-family: -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, &quot;Noto Sans&quot;, Helvetica, Arial, sans-serif, &quot;Apple Color Emoji&quot;, &quot;Segoe UI Emoji&quot;; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(244, 246, 248);"><span style="box-sizing: border-box; border-width: 0px; border-style: solid; border-color: rgb(229, 231, 235); --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgb(59 130 246 / .5); --tw-ring-offset-shadow: 0 0 #0000; --tw-ring-shadow: 0 0 #0000; --tw-shadow: 0 0 #0000; --tw-shadow-colored: 0 0 #0000; font-size: 1.25em; line-height: 1.25; color: rgb(36, 41, 47); font-family: -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, &quot;Noto Sans&quot;, Helvetica, Arial, sans-serif, &quot;Apple Color Emoji&quot;, &quot;Segoe UI Emoji&quot;; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(244, 246, 248);">总结</span></h3><ul style="box-sizing: border-box; border-width: 0px; border-style: solid; border-color: rgb(229, 231, 235); --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgb(59 130 246 / .5); --tw-ring-offset-shadow: 0 0 #0000; --tw-ring-shadow: 0 0 #0000; --tw-shadow: 0 0 #0000; --tw-shadow-colored: 0 0 #0000; list-style: disc; margin: 0px 0px 16px; padding: 0px 0px 0px 2em; color: rgb(36, 41, 47); font-family: -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, &quot;Noto Sans&quot;, Helvetica, Arial, sans-serif, &quot;Apple Color Emoji&quot;, &quot;Segoe UI Emoji&quot;; font-size: 14px; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(244, 246, 248);"><li style="box-sizing: border-box; border-width: 0px; border-style: solid; border-color: rgb(229, 231, 235); --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-pan-x: ; --tw-pan-y: ; --tw-pinch-zoom: ; --tw-scroll-snap-strictness: proximity; --tw-ordinal: ; --tw-slashed-zero: ; --tw-numeric-figure: ; --tw-numeric-spacing: ; --tw-numeric-fraction: ; --tw-ring-inset: ; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgb(59 130 246 / .5); --tw-ring-offset-shadow: 0 0 #0000; --tw-ring-shadow: 0 0 #0000; --tw-shadow: 0 0 #0000; --tw-shadow-colored: 0 0 #0000; --tw-blur: ; --tw-brightness: ; --tw-contrast: ; --tw-grayscale: ; --tw-hue-rotate: ; --tw-invert: ; --tw-saturate: ; --tw-sepia: ; --tw-drop-shadow: ; --tw-backdrop-blur: ; --tw-backdrop-brightness: ; --tw-backdrop-contrast: ; --tw-backdrop-grayscale: ; --tw-backdrop-hue-rotate: ; --tw-backdrop-invert: ; --tw-backdrop-opacity: ; --tw-backdrop-saturate: ; --tw-backdrop-sepia: ;"><div><span style="font-weight: bold; box-sizing: border-box; border-width: 0px; border-style: solid; border-color: rgb(229, 231, 235); --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgb(59 130 246 / .5); --tw-ring-offset-shadow: 0 0 #0000; --tw-ring-shadow: 0 0 #0000; --tw-shadow: 0 0 #0000; --tw-shadow-colored: 0 0 #0000;">Anchor</span>：决定UI元素相对于父容器的位置。调整<span style="box-sizing: border-box; border-width: 0px; border-style: solid; border-color: rgb(229, 231, 235); --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgb(59 130 246 / .5); --tw-ring-offset-shadow: 0 0 #0000; --tw-ring-shadow: 0 0 #0000; --tw-shadow: 0 0 #0000; --tw-shadow-colored: 0 0 #0000; font-family: ui-monospace, SFMono-Regular, &quot;SF Mono&quot;, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-size: 11.9px; white-space: break-spaces; background-color: var(--color-neutral-muted); border-radius: 6px;">Anchor</span>可以使UI元素在父容器大小变化时自动调整位置。</div></li><li style="box-sizing: border-box; border-width: 0px; border-style: solid; border-color: rgb(229, 231, 235); --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-pan-x: ; --tw-pan-y: ; --tw-pinch-zoom: ; --tw-scroll-snap-strictness: proximity; --tw-ordinal: ; --tw-slashed-zero: ; --tw-numeric-figure: ; --tw-numeric-spacing: ; --tw-numeric-fraction: ; --tw-ring-inset: ; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgb(59 130 246 / .5); --tw-ring-offset-shadow: 0 0 #0000; --tw-ring-shadow: 0 0 #0000; --tw-shadow: 0 0 #0000; --tw-shadow-colored: 0 0 #0000; --tw-blur: ; --tw-brightness: ; --tw-contrast: ; --tw-grayscale: ; --tw-hue-rotate: ; --tw-invert: ; --tw-saturate: ; --tw-sepia: ; --tw-drop-shadow: ; --tw-backdrop-blur: ; --tw-backdrop-brightness: ; --tw-backdrop-contrast: ; --tw-backdrop-grayscale: ; --tw-backdrop-hue-rotate: ; --tw-backdrop-invert: ; --tw-backdrop-opacity: ; --tw-backdrop-saturate: ; --tw-backdrop-sepia: ; margin-top: 0.25em;"><div><span style="font-weight: bold; box-sizing: border-box; border-width: 0px; border-style: solid; border-color: rgb(229, 231, 235); --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgb(59 130 246 / .5); --tw-ring-offset-shadow: 0 0 #0000; --tw-ring-shadow: 0 0 #0000; --tw-shadow: 0 0 #0000; --tw-shadow-colored: 0 0 #0000;">Pivot</span>：决定UI元素自身的旋转和缩放的中心点。调整<span style="box-sizing: border-box; border-width: 0px; border-style: solid; border-color: rgb(229, 231, 235); --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgb(59 130 246 / .5); --tw-ring-offset-shadow: 0 0 #0000; --tw-ring-shadow: 0 0 #0000; --tw-shadow: 0 0 #0000; --tw-shadow-colored: 0 0 #0000; font-family: ui-monospace, SFMono-Regular, &quot;SF Mono&quot;, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-size: 11.9px; white-space: break-spaces; background-color: var(--color-neutral-muted); border-radius: 6px;">Pivot</span>不会影响UI元素在父容器中的位置，只影响其变换的参考点。</div></li></ul></div></span>
</div>
<hr>
<a name="551"/>

<div>
<span><div><div><span style="font-size: 12pt; font-family: Eurostile;">UniTask</span></div><div><span style="font-size: 12pt; font-family: Eurostile;">文档:</span> <span style="font-size: 12pt; font-family: Eurostile;"><a href="https://www.lfzxb.top/unitask_reademe_cn/#unitask-%E5%92%8C-asyncoperation-%E5%9F%BA%E7%A1%80%E7%9F%A5%E8%AF%86">UniTask中文文档 | 烟雨迷离半世殇的成长之路 (lfzxb.top)</a></span></div><ol><li><div><span style="font-size: 12pt; font-family: Eurostile;">UniTask.UnityAction: 通常给按钮添加绑定事件时用到,传入一个func&lt;UnitaskVoid&gt;;</span></div></li><li><div><span style="font-size: 12pt; font-family: Eurostile;">取消任务:CancellationTokenSource,</span></div></li></ol><ul><li><div><span style="font-size: 12pt; font-family: Eurostile;">    只能使用一次.任务中传入cts.token,并在需要的时候调用cts.cancel就可以取消任务;该类为非托管类使用完需要手动调用dispose去销毁</span></div></li><li><div><span style="font-size: 12pt; font-family: Eurostile;">    取消后会抛出operationCancel的异常可以用try_catch接入.</span></div></li><li><div><span style="font-size: 12pt; font-family: Eurostile;">    </span><span style="font-size: 12pt; font-family: Eurostile;">忽略报错:</span><span style="font-size: 12pt; font-family: Eurostile;">出于性能考虑可以使用拓展方法SuppressCancellationThrow()去忽略报错,这个方法有一个固定的返回值:Iscancel,其余的返回值需要依据具体的task&lt;t&gt;来定=&gt;     var&lt;bool,t&gt;</span></div></li><ul><li><div><span style="font-size: 12pt; font-family: Eurostile;">             g  :</span><span style="font-size: 12pt; font-family: Eurostile;">var(iscancle, result) = await  </span><span style="font-size: 12pt; color: unset; font-family: Eurostile;">UnityWebRequest.Get(url).SendWebRequest().WithCancellation(cts.Token).SuppressCancellationThrow();</span></div></li></ul><li><div><span style="font-size: 12pt; color: unset; font-family: Eurostile;">    自动取消(超时): </span><span style="font-size: 12pt; font-family: Eurostile;">cts.CancelAfterSlim(TimeSpan.FromSeconds(3));]</span></div></li><ul><li><div><span style="font-size: 12pt; font-family: Eurostile;">TimeoutController: 超时取消,reset后可以重复使用,注意程序需要处理tumeOut的异常;还可以和Cancellation一起使用:</span><span style="font-size: 12pt; font-family: Eurostile;">new TimeoutController(CancellationToken).</span></div></li></ul><li><div><span style="font-size: 12pt; font-family: Eurostile;">    *手动和超时可以组合起来使用: </span></div></li><ul><li><div><span style="font-size: 12pt; font-family: Eurostile;">    var linkedTokenSource = CancellationTokenSource.CreateLinkedTokenSource(cancelToken.Token, timeoutToken.Token)//绑定手动和超时的token</span></div></li><li><div><span style="font-size: 12pt; color: unset; font-family: Eurostile;">   await UnityWebRequest.Get(&quot;http://foo&quot;).SendWebRequest().WithCancellation(linkedTokenSource.Token);</span></div></li></ul><li><div><span style="font-size: 12pt; font-family: Eurostile;">    GanmeObject有自带的取消类:</span><span style="font-family: Eurostile; font-size: 12pt;">await UniTask.DelayFrame(1000, cancellationToken:</span> <span style="font-family: Eurostile; font-size: 12pt; text-decoration: underline;">this.GetCancellationTokenOnDestroy()</span><span style="font-family: Eurostile; font-size: 12pt;">);</span></div></li></ul><div><br/></div></div><div><br/></div></span>
</div>
<hr>
<a name="553"/>

<div>
<span><div><div>AStar寻路</div><div>        文档: <a href="https://www.gamedev.net/tutorials/_/technical/artificial-intelligence/a-pathfinding-for-beginners-r2003/">A* Pathfinding for Beginners - Artificial Intelligence - Tutorials - GameDev.net</a></div><div>             <a href="https://zhuanlan.zhihu.com/p/385733813">A-Star（A*）寻路算法原理与实现 - 知乎 (zhihu.com)</a></div><ol><li><div>不停的找自己周围的点,选出一个新的点作为起点再循环的找</div></li><li><div>f(寻路消耗) = g(离起点的距离)+h(预估的终点距离);待处理的点集合;不再处理的点集合;节点的父对象</div></li><li><div>g 和 h 的计算方式:</div></li><ol><li><div>欧几里得距离:两点间的直线距离  <span style="font-size: medium; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; color: rgb(25, 27, 31); font-family: -apple-system, BlinkMacSystemFont, &quot;Helvetica Neue&quot;, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Source Han Sans SC&quot;, &quot;Noto Sans CJK SC&quot;, &quot;WenQuanYi Micro Hei&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: bold;">h(n) 的值永远小于或等于格子n到终点的最短实际距离。</span></div></li><li><div>曼哈顿距离;两点间xy方向的总和; <span style="font-size: medium; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255); color: rgb(25, 27, 31); font-family: -apple-system, BlinkMacSystemFont, &quot;Helvetica Neue&quot;, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Source Han Sans SC&quot;, &quot;Noto Sans CJK SC&quot;, &quot;WenQuanYi Micro Hei&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">，</span><span style="font-size: medium; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; color: rgb(25, 27, 31); font-family: -apple-system, BlinkMacSystemFont, &quot;Helvetica Neue&quot;, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Source Han Sans SC&quot;, &quot;Noto Sans CJK SC&quot;, &quot;WenQuanYi Micro Hei&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: bold;">曼哈顿距离肯定大于或等于格子n到终点的最短实际距离。</span></div></li><ol><li><div>由12可以看得出,预估的h最大是曼哈顿,最小是欧几里得;因可以看作三角形,两边之和大于第三边</div></li></ol><li><div>对角线+直线: 找出两个点之间最大的正方形,做对角线 + 剩余的直线</div></li><li><div><b>*为什么欧几里得距离的h值会&lt;=到终点的实际距离?曼哈顿距离&gt;=n到终点的实际距离呢?</b></div></li><ol><ol><li><div>实际场景可能存在障碍或者起点和终点不能构成正方形这样就会导致欧几里得的拉直线的算法估值和实际行动消耗对不上</div></li><li><div>同理曼哈顿距离的估值算法是将对角线移动的情况排除了,估算的结果会最好情况是完全不走对角线</div></li><li><div><span style="color: rgb(25, 27, 31); font-family: -apple-system, BlinkMacSystemFont, &quot;Helvetica Neue&quot;, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Source Han Sans SC&quot;, &quot;Noto Sans CJK SC&quot;, &quot;WenQuanYi Micro Hei&quot;, sans-serif; font-size: medium; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal;">既然可以对角线移动，那么就可以根据水平方向的差值与竖直方向的分量中较小的那个值，计算出对角线，然后再平移<b>(</b></span><b><span style="color: rgb(25, 27, 31);">对角线+直线</span><span style="color: rgb(25, 27, 31); font-family: -apple-system, BlinkMacSystemFont, &quot;Helvetica Neue&quot;, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Source Han Sans SC&quot;, &quot;Noto Sans CJK SC&quot;, &quot;WenQuanYi Micro Hei&quot;, sans-serif; font-size: medium; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal;">)</span></b></div></li></ol></ol></ol><li><div>计算周围8个格子的消耗,如果本次计算的G值大于之前的,说明不是最短路径,不更新;选出最小消耗的点,然后重复该步骤;知道发现周围格是终点时停止</div></li><li><div>反转路径列表</div></li><li><div>实现要点:</div></li><ol><li><div>格子数据包含 位置, F值, G,H ,上一个节点信息</div></li><li><div>Open结构用于存储周围格; close用于存储最小消耗格</div></li><ol><li><div>获取open中最小的格子</div></li><li><div>最小格从open中移除放入close,新增周围未计算的格子放入open,对于已经在open中的格子就更新信息</div></li></ol></ol></ol><div><br/></div><div>        </div></div><div><br/></div></span>
</div>
<hr>
<a name="555"/>

<div>
<span><div><div>六边形网格地图</div><div><br/></div><div> 参考文档 :  <a href="https://www.redblobgames.com/grids/hexagons/#conversions">六边形网格 (redblobgames.com)</a> </div><div><a href="https://zhuanlan.zhihu.com/p/59705625">https://zhuanlan.zhihu.com/p/59705625</a></div><div>      <a href="https://catlikecoding.com/unity/tutorials/hex-map/part-1/" style="outline: none; overflow-wrap: break-word; font-size: 16px; color: rgb(78, 161, 219); font-family: -apple-system, &quot;SF UI Text&quot;, Arial, &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, &quot;WenQuanYi Micro Hei&quot;, sans-serif, SimHei, SimSun;">https://catlikecoding.com/unity/tutorials/hex-map/part-1/</a>  </div><div><a href="https://indienova.com/indie-game-development/hex-grids-reference/#iah-12">https://indienova.com/indie-game-development/hex-grids-reference/#iah-12</a></div><div> <a href="https://www.cnblogs.com/LittleTiger/p/4611028.html">https://www.cnblogs.com/LittleTiger/p/4611028.html</a></div><div>  <a href="https://blog.csdn.net/vikingsc2007_1/article/details/77621491">https://blog.csdn.net/vikingsc2007_1/article/details/77621491</a></div><div>有个游戏物体想要展示3D模型需要两个组件:Mesh Filter 和 Mesh Randerer </div><div>通常Mesh的最小单位三角形是需要顺时针定位,逆时针的三角形不会渲染</div><div><br/></div><div>理论部分:</div><div>六边形分为内径和外径对应内接圆和外切圆,下文size为外径,对应的高度宽度如下图</div><div><span style="font-size: 11pt; color: rgb(51, 51, 51); font-family: &quot;Helvetica Neue&quot;; font-weight: bold;">六边形摆放方法:平顶/尖顶</span></div><div><img src="Evernote_files/Image [15].png" type="image/png" data-filename="Image.png"/></div><div><br/></div><div><br/></div><div><br/></div><ul><li><div> 弧度制:用符号Rad表示  <span style="font-size: 14px; letter-spacing: normal; orphans: 2; text-indent: 28px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; color: rgb(51, 51, 51); font-family: &quot;Helvetica Neue&quot;, Helvetica, Arial, &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, &quot;WenQuanYi Micro Hei&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: bold;">|弧度|=弧长÷半径 </span> <span style="font-size: 14px; letter-spacing: normal; orphans: 2; text-indent: 28px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; color: rgb(51, 51, 51); font-family: &quot;Helvetica Neue&quot;, Helvetica, Arial, &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, &quot;WenQuanYi Micro Hei&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">对应的弧长与圆半径之比来度量角度</span></div></li></ul><div><span style="font-size: 11pt;"><span style="font-size: 11pt; color: rgb(51, 51, 51); font-family: &quot;Helvetica Neue&quot;; font-weight: bold;"><img src="Evernote_files/Image [16].png" type="image/png" data-filename="Image.png"/></span></span></div><div><span style="font-size: 11pt;"><br/></span></div><div><span style="font-size: 11pt;"><span style="font-size: 11pt;"><br/></span></span></div><div><span style="font-size: 11pt;"><span style="font-size: 11pt;"><br/></span></span></div><div>渲染一个六边形步骤:</div><div>设定 面 的数据结构: 包含顶点, 三角形索引 和 uv坐标 </div><div>六边形的每个顶点的计算公式 弧度制计算坐标 x = r * cos(a);  y = r * sin(a); 其中a代表弧度,由于六边形有两种常见的摆放方法,计算弧度也会有所不同:</div><div><img src="Evernote_files/Image [17].png" type="image/png" data-filename="Image.png"/></div><div><img src="Evernote_files/Image [18].png" type="image/png" data-filename="Image.png"/></div><div><br/></div></div><div><br/></div></span>
</div>
<hr>
<a name="557"/>

<div>
<span><div><div>软件设计师</div><ul><li><div>数据的表示</div></li><ul><li><div>十进制转二进制,短除法,得到的结果从后边取</div></li><li><div>原码,反码,补码,移码</div></li><ul><li><div>正数的反码补码不变,负数的反码除符号位全部取反,负数的补码在反码的基础上+1,负数的补码转源码:符号位外取反+1</div></li><li><div>补码:用于整形的加减法运算</div></li><li><div>移码:在补码的基础上符号位取反,用在浮点运算中做阶码</div></li></ul></ul></ul><div>    </div></div><div><br/></div></span>
</div>
<hr>
<a name="559"/>

<div>
<span><div>《游戏编程模式》个人见解</div><div>对于模块的设计需要三点： 解耦 抽象 支持拓展</div><div>享原模式： 优化三消游戏，代表方块的类不需要依据方块数量决定，而是依据种类决定的5种方块就只需要构建5个实例。位置是外部属性，在数组中直接存实例的引用就行 </div><div>单例模式： 使用这个模式的场景绕不开两个问题：1、不需要多个实例2、方便调用； 对于一个模块是否只需要一个实例这个有待商榷。 使用这个模式会使代码耦合，对并发程序也不友好</div><div>    但是一些场景是不需要使用单例模式的，xxxManager，开发功能时警惕把类自身的功能外移，这会创造不必要的Manager类。<b>让对象自己管理自己</b><br/></div></span>
</div>
<hr>
<a name="561"/>

<div>
<span><div><font style="font-size: 24pt;"><span style="font-size: 24pt; font-weight: bold;">随笔</span></font></div><div>任务调度模块</div><div>全局消息模块</div><div>本地缓存模块</div><div>ui节点队列</div><div>inject fix不能使用的场景: action-=;新增字段;访问静态字段;异步编程模式</div><div>热更UI基类</div><div>线性探测法保证不重复</div><div>UINotice管理模块</div><div>红点树系统</div><div>1.特性就像是附着物,成员的额外附加属性</div><div><img src="Evernote_files/Image [19].png" type="image/png" data-filename="Image.png" width="733"/></div><div><br/></div></span>
</div>
<hr>
<a name="563"/>

<div>
<span><div><div>最小堆</div><div><span style="font-weight: bold;">为何（Why）何事（What）</span><span style="font-weight: bold; text-decoration: line-through;">何人（Who</span><span style="font-weight: bold;">）何时（When）何地（Where）</span></div><div><span style="font-weight: bold;">如何（How）何价（How mach）</span></div><div><span style="font-weight: bold;"><br/></span></div><div><span style="font-weight: bold;"><br/></span></div><div>What: 最小堆结构是一个有序的完全二叉树(深度为h的二叉树,h-1层的结点都是满的状态,第h层开始由左子树开始填充),</div><div><span>    </span>根节点的值是最小的,并且所有节点的值都不大于其子节点</div><div>when&amp;where: 优先队列,堆排序, <span style="color: rgb(36, 41, 47); font-family: -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, &quot;Noto Sans&quot;, Helvetica, Arial, sans-serif, &quot;Apple Color Emoji&quot;, &quot;Segoe UI Emoji&quot;; font-size: 14px; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: pre-wrap; background-color: rgb(244, 246, 248);">Dijkstra</span>算法等</div><div>how:构建过程关键点</div><div>1.n个待排序的数据如何变成堆?</div><ol><li><div>对n个元素进行反复筛选的过程</div></li></ol><div>2.如何调整n-1个2数据使其变成新堆?</div><ol><li><div>假设有m个元素,删除根节点后将最后一个元素放入根节点作为临时根节点;这时堆的排序会被破坏,</div></li><li><div>将临时节点和左右子节点中更小的进行交换,如果不满足最小堆规则继续重复该步骤</div></li><li><div>直到目标元素处于最底层的叶节点</div></li></ol><div><span>    </span><br/></div></div></span>
</div>
<hr>
<a name="565"/>

<div>
<span><div><font style="font-size: 18pt;"><span style="font-size: 18pt; font-weight: bold;">解决方案和项目</span></font></div><div><img src="Evernote_files/Image [20].png" type="image/png" data-filename="Image.png"/></div><div><br/></div><div><img src="Evernote_files/Image [21].png" type="image/png" data-filename="Image.png"/></div><div>.sln  是解决方案</div><div><span style="color: rgb(22, 22, 22); font-family: &quot;Segoe UI&quot;, SegoeUI, &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; font-size: 16px; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal;">.csproj 是项目 </span></div><div><br/></div></span>
</div>
<hr>
<a name="572"/>

<div>
<span><div><h1 style="box-sizing: border-box; outline: 0px; margin: 0px; padding: 0px; font-size: 28px; overflow-wrap: break-word; word-break: break-all; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255);"><span style="box-sizing: border-box; outline: 0px; font-size: 28px; overflow-wrap: break-word; word-break: break-all; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; color: rgb(34, 34, 38); font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, SimHei, Arial, SimSun; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: bold;">齐次坐标的理解 </span></h1><div><span style="font-size: 21pt;"><a href="https://blog.csdn.net/janestar/article/details/44244849" style="font-family: &quot;PingFang SC&quot;; font-size: 21pt; font-weight: bold;">关于齐次坐标的理解（经典）_c# 齐次坐标-CSDN博客</a></span></div><div><a href="https://www.songho.ca/math/homogeneous/homogeneous.html">Homogeneous Coordinates (songho.ca)</a></div><div><br/></div></div><div>简单的说,齐次坐标就是用N+1维去表示N维</div></span>
</div>
<hr>
<a name="576"/>

<div>
<span><div>依赖注入框架</div><div>思路: 利用特性[Attribute]和反射技术,在游戏开始时获取提供注入的类,放入内存中;再分配给需要注入的字段,属性和方法</div><div>//1.定义一个提供依赖的类，实现IDependencyProvider接口</div><div>//2.在提供依赖的方法上添加ProvideAttribute特性</div><div>//3.在需要注入依赖的类中添加InjectAttribute特性</div><div>//4.在需要注入依赖的字段、方法或属性上添加InjectAttribute特性</div><div>//5.在需要注入依赖的方法中添加一个参数，参数类型为需要注入的类型</div><div><br/></div><div>目前只了解到如何针对<u>场景中已经存在的MonoBehavior</u>进行反射获取,依赖注入的操作;对于需要其他时机生成的普通类的依赖注入不知道解决方案</div><div><br/></div><div>依赖注入可以摆脱单例模式的写法,可以和具体类解耦(游戏中的各种单例管理类</div></span>
</div>
<hr>
<a name="578"/>

<div>
<span><div><div><div><span style="font-size: 1.728em; color: rgb(51, 51, 51); font-family: &quot;Roboto Slab&quot;, &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; font-weight: bold;">代码是如何被执行的？</span></div><div style="margin: 0px 0px 14.4px; font-size: 16px; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal;"><span style="font-size: 16px; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; color: rgb(51, 51, 51); font-family: &quot;Open Sans&quot;, &quot;Helvetica Neue&quot;, Helvetica, Roboto, Arial, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">所有代码都是这样被执行的：从源代码开始，经过</span><span style="font-size: 16px; color: rgb(51, 51, 51); font-family: &quot;Open Sans&quot;, &quot;Helvetica Neue&quot;, Helvetica, Roboto, Arial, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; text-decoration: underline;">一系列转换</span><span style="font-size: 16px; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; color: rgb(51, 51, 51); font-family: &quot;Open Sans&quot;, &quot;Helvetica Neue&quot;, Helvetica, Roboto, Arial, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">，最终生成机器码（有时候也叫原生码，或本地码），由CPU执行。</span></div><h3 style="font-size: 1.44em; margin: 0px 0px 1rem; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal;"><span style="font-size: 1.44em; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; color: rgb(51, 51, 51); font-family: &quot;Roboto Slab&quot;, &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; line-height: 1.8;">编译</span></h3><div style="margin: 0px 0px 14.4px; font-size: 16px; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal;"><span style="font-size: 16px; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; color: rgb(51, 51, 51); font-family: &quot;Open Sans&quot;, &quot;Helvetica Neue&quot;, Helvetica, Roboto, Arial, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">我们把代码的这种</span><span style="font-size: 16px; color: rgb(51, 51, 51); font-family: &quot;Open Sans&quot;, &quot;Helvetica Neue&quot;, Helvetica, Roboto, Arial, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; text-decoration: underline;">转换</span><span style="font-size: 16px; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; color: rgb(51, 51, 51); font-family: &quot;Open Sans&quot;, &quot;Helvetica Neue&quot;, Helvetica, Roboto, Arial, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">叫做编译，编译就是把更高层的A语言代码转换为更底层的B语言代码的一种行为。编译产出的其实是另一种语言，并</span><span style="font-size: 16px; color: rgb(51, 51, 51); font-family: &quot;Open Sans&quot;, &quot;Helvetica Neue&quot;, Helvetica, Roboto, Arial, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; text-decoration: underline;">不涉及代码的执行</span><span style="font-size: 16px; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; color: rgb(51, 51, 51); font-family: &quot;Open Sans&quot;, &quot;Helvetica Neue&quot;, Helvetica, Roboto, Arial, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">。编译器（Compiler）就是可以执行编译行为的程序。</span></div><div style="margin: 0px 0px 14.4px; font-size: 16px; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal;"><span style="font-size: 16px; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; color: rgb(51, 51, 51); font-family: &quot;Open Sans&quot;, &quot;Helvetica Neue&quot;, Helvetica, Roboto, Arial, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">可以把程序的生命周期分为CompileTime和RunTime。一个程序开始执行，就进入RunTime周期。</span><span style="font-size: 16px; color: rgb(51, 51, 51); font-family: &quot;Open Sans&quot;, &quot;Helvetica Neue&quot;, Helvetica, Roboto, Arial, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; text-decoration: underline;">根据编译的时机是在CompileTime还是RunTime</span><span style="font-size: 16px; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; color: rgb(51, 51, 51); font-family: &quot;Open Sans&quot;, &quot;Helvetica Neue&quot;, Helvetica, Roboto, Arial, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">，我们可以分为两种： AOT（Ahead-Of-Time）编译器和JIT（Just-In-Time）编译器，其中的Time，就是指RunTime。</span></div><h3 style="font-size: 1.44em; margin: 0px 0px 1rem; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal;"><span style="font-size: 1.44em; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; color: rgb(51, 51, 51); font-family: &quot;Roboto Slab&quot;, &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; line-height: 1.8;">解释</span></h3><div style="margin: 0px 0px 14.4px; font-size: 16px; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal;"><span style="font-size: 16px; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; color: rgb(51, 51, 51); font-family: &quot;Open Sans&quot;, &quot;Helvetica Neue&quot;, Helvetica, Roboto, Arial, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">还有一个动词经常和编译一起出现，就是“解释”。解释器（Interpreter）执行代码的过程就叫解释，解释器的作用是，在运行时读取代码并执行。解释器最终会执行代码，但并不规定如何执行代码，可能其中就夹杂着编译的过程（例如JIT）。</span></div><div style="margin: 0px 0px 14.4px; font-size: 16px; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal;"><span style="font-size: 16px; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; color: rgb(51, 51, 51); font-family: &quot;Open Sans&quot;, &quot;Helvetica Neue&quot;, Helvetica, Roboto, Arial, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">编译器：</span></div><ul style="list-style-type: disc; margin-bottom: 1em; padding-left: 28.8px; font-size: 16px; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal;"><li style="box-sizing: inherit;"><div><span style="font-size: 16px; color: rgb(51, 51, 51); font-family: &quot;Open Sans&quot;, &quot;Helvetica Neue&quot;, Helvetica, Roboto, Arial, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">本质是输入代码，输出另一种代码</span></div></li><ul style="box-sizing: inherit; list-style-type: disc; margin-bottom: 1em; padding-left: 28.8px;"><li style="box-sizing: inherit;"><div><span style="font-size: 16px; color: rgb(51, 51, 51); font-family: &quot;Open Sans&quot;, &quot;Helvetica Neue&quot;, Helvetica, Roboto, Arial, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">一般会分为多层，经过多次转换，最终生成机器码，给CPU执行</span></div></li><li style="box-sizing: inherit;"><div><span style="font-size: 16px; color: rgb(51, 51, 51); font-family: &quot;Open Sans&quot;, &quot;Helvetica Neue&quot;, Helvetica, Roboto, Arial, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">JIT、AOT、Full AOT等，是不同的编译策略</span></div></li></ul></ul><div style="margin: 0px 0px 14.4px; font-size: 16px; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal;"><span style="font-size: 16px; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; color: rgb(51, 51, 51); font-family: &quot;Open Sans&quot;, &quot;Helvetica Neue&quot;, Helvetica, Roboto, Arial, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">解释器：</span></div><ul style="list-style-type: disc; margin-bottom: 1em; padding-left: 28.8px; font-size: 16px; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal;"><li style="box-sizing: inherit;"><div><span style="font-size: 16px; color: rgb(51, 51, 51); font-family: &quot;Open Sans&quot;, &quot;Helvetica Neue&quot;, Helvetica, Roboto, Arial, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">本质是输入代码，输出结果</span></div></li><ul style="box-sizing: inherit; list-style-type: disc; margin-bottom: 1em; padding-left: 28.8px;"><li style="box-sizing: inherit;"><div><span style="font-size: 16px; color: rgb(51, 51, 51); font-family: &quot;Open Sans&quot;, &quot;Helvetica Neue&quot;, Helvetica, Roboto, Arial, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">在程序运行时执行</span></div></li><li style="box-sizing: inherit;"><div><span style="font-size: 16px; color: rgb(51, 51, 51); font-family: &quot;Open Sans&quot;, &quot;Helvetica Neue&quot;, Helvetica, Roboto, Arial, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">是一个黑箱，内部实现方式不确定，经常也可以用编译的方式来实现</span></div></li><li style="box-sizing: inherit;"><div><span style="font-size: 16px; color: rgb(51, 51, 51); font-family: &quot;Open Sans&quot;, &quot;Helvetica Neue&quot;, Helvetica, Roboto, Arial, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">不是不需要编译，只是不需要用户显式地使用编译器来得到可执行代码</span></div></li></ul></ul><div><span style="font-size: 12pt; color: rgb(51, 51, 51); font-family: &quot;Open Sans&quot;;"><img src="Evernote_files/Image.jpg" type="image/jpeg" data-filename="Image.jpg"/></span></div><div><span style="letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal;"><span style="font-size: 14pt; color: rgb(25, 27, 31); font-family: -apple-system, BlinkMacSystemFont, &quot;Helvetica Neue&quot;, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Source Han Sans SC&quot;, &quot;Noto Sans CJK SC&quot;, &quot;WenQuanYi Micro Hei&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: bold;">IL</span></span></div><div><span style="letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal;"><span style="font-size: 12pt; color: rgb(25, 27, 31); font-family: -apple-system, BlinkMacSystemFont, &quot;Helvetica Neue&quot;, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Source Han Sans SC&quot;, &quot;Noto Sans CJK SC&quot;, &quot;WenQuanYi Micro Hei&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">IL的全称是 Intermediate Language，很多时候还会看到CIL（Common Intermediate Language，特指在.Net平台下的IL标准）。在Unity博客和本文中,IL和CIL表示的是同一个东西：翻译过来就是</span><span style="font-size: 12pt; color: rgb(25, 27, 31); font-family: -apple-system, BlinkMacSystemFont, &quot;Helvetica Neue&quot;, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Source Han Sans SC&quot;, &quot;Noto Sans CJK SC&quot;, &quot;WenQuanYi Micro Hei&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; text-decoration: underline;">中间语言</span><span style="font-size: 12pt; color: rgb(25, 27, 31); font-family: -apple-system, BlinkMacSystemFont, &quot;Helvetica Neue&quot;, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Source Han Sans SC&quot;, &quot;Noto Sans CJK SC&quot;, &quot;WenQuanYi Micro Hei&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">。它是一种属于 通用语言架构和.NET框架的低阶（lowest-level）的人类可读的编程语言。目标为.NET框架的语言被编译成CIL，然后汇编成字节码。 CIL类似一个面向对象的汇编语言，并且它是完全基于堆栈的，</span><span style="font-size: 12pt; color: rgb(25, 27, 31); font-family: -apple-system, BlinkMacSystemFont, &quot;Helvetica Neue&quot;, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Source Han Sans SC&quot;, &quot;Noto Sans CJK SC&quot;, &quot;WenQuanYi Micro Hei&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; text-decoration: underline;">它运行在虚拟机上（.Net Framework, Mono VM）的语言</span><span style="font-size: 12pt; color: rgb(25, 27, 31); font-family: -apple-system, BlinkMacSystemFont, &quot;Helvetica Neue&quot;, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Source Han Sans SC&quot;, &quot;Noto Sans CJK SC&quot;, &quot;WenQuanYi Micro Hei&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">。</span></span></div><div><span style="letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal;"><span style="font-size: 12pt; color: rgb(25, 27, 31); font-family: -apple-system, BlinkMacSystemFont, &quot;Helvetica Neue&quot;, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Source Han Sans SC&quot;, &quot;Noto Sans CJK SC&quot;, &quot;WenQuanYi Micro Hei&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">具体过程是：C#或者VB这样遵循CLI规范的高级语言，被先被各自的编译器编译成中间语言：IL（CIL），</span><span style="font-size: 12pt; color: rgb(25, 27, 31); font-family: -apple-system, BlinkMacSystemFont, &quot;Helvetica Neue&quot;, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Source Han Sans SC&quot;, &quot;Noto Sans CJK SC&quot;, &quot;WenQuanYi Micro Hei&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; text-decoration: underline;">等到需要真正执行的时候，这些IL会被加载到运行时库，也就是VM中，由VM动态的编译成汇编代码（JIT）然后在执行。</span></span></div><div><span style="font-size: 14pt; color: rgb(51, 51, 51); font-family: &quot;Open Sans&quot;; font-weight: bold;">Mono和IL2CPP</span></div><div><span style="font-size: 12pt; color: rgb(51, 51, 51); font-family: &quot;Open Sans&quot;;">Mono的编译流程:</span> <span style="font-size: 16px; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; color: rgb(51, 51, 51); font-family: &quot;Open Sans&quot;, &quot;Helvetica Neue&quot;, Helvetica, Roboto, Arial, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">C# 编译成 CIL（dll）字节码，由Mono VM运行</span></div><div><span style="font-size: 12pt; color: rgb(51, 51, 51); font-family: &quot;Open Sans&quot;;"><img src="Evernote_files/Image [22].png" type="image/png" data-filename="Image.png"/></span></div><div><span style="font-size: 12pt;"><br/></span></div><div><span style="font-size: 12pt; color: rgb(51, 51, 51); font-family: &quot;Open Sans&quot;;">IL2CPP编译流程:</span> <span style="font-size: 16px; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; color: rgb(51, 51, 51); font-family: &quot;Open Sans&quot;, &quot;Helvetica Neue&quot;, Helvetica, Roboto, Arial, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">C# 编译成 CIL，裁剪后，再由il2cpp.exe编译成C++代码，再交给对应平台的编译器，编译成对应平台的机器码，链接上libil2cpp库（IL2CPP VM），然后运行</span></div><div><span style="font-size: 12pt; color: rgb(51, 51, 51); font-family: &quot;Open Sans&quot;;"><img src="Evernote_files/Image [23].png" type="image/png" data-filename="Image.png"/></span></div><h2 style="font-family: &quot;Roboto Slab&quot;, &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; font-size: 1.728em; line-height: 1.8; margin: 0px 0px 1rem; color: rgb(51, 51, 51); font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal;"></h2><h2 style="font-size: 1.728em; margin: 0px 0px 1rem; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal;"><span style="font-size: 1.728em; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; color: rgb(51, 51, 51); font-family: &quot;Roboto Slab&quot;, &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: bold; line-height: 1.8;">热更新本质上是什么？</span></h2><div style="margin: 0px 0px 14.4px; font-size: 16px; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal;"><span style="font-size: 16px; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; color: rgb(51, 51, 51); font-family: &quot;Open Sans&quot;, &quot;Helvetica Neue&quot;, Helvetica, Roboto, Arial, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">热更本质上是，在运行时，执行新的逻辑。要达到这个目的，实际上有两种方式：</span></div><ul style="list-style-type: disc; margin-bottom: 1em; padding-left: 28.8px; font-size: 16px; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal;"><li style="box-sizing: inherit;"><div><span style="font-size: 16px; color: rgb(51, 51, 51); font-family: &quot;Open Sans&quot;, &quot;Helvetica Neue&quot;, Helvetica, Roboto, Arial, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; text-decoration: underline;">执行新的机器码</span></div></li><ul style="box-sizing: inherit; list-style-type: disc; margin-bottom: 1em; padding-left: 28.8px;"><li style="box-sizing: inherit;"><div><span style="font-size: 16px; color: rgb(51, 51, 51); font-family: &quot;Open Sans&quot;, &quot;Helvetica Neue&quot;, Helvetica, Roboto, Arial, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">C#的托管Dll：下载dll（字节码），运行时加载，使用Mono的JIT方式编译执行</span></div></li><li style="box-sizing: inherit;"><div><span style="font-size: 16px; color: rgb(51, 51, 51); font-family: &quot;Open Sans&quot;, &quot;Helvetica Neue&quot;, Helvetica, Roboto, Arial, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">本地（Native）Dll：下载dll（机器码），加载到内存里，执行</span></div></li></ul><li style="box-sizing: inherit;"><div><span style="font-size: 16px; color: rgb(51, 51, 51); font-family: &quot;Open Sans&quot;, &quot;Helvetica Neue&quot;, Helvetica, Roboto, Arial, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">按照不同的顺序，执行原有的代码</span></div></li><ul style="box-sizing: inherit; list-style-type: disc; margin-bottom: 1em; padding-left: 28.8px;"><li style="box-sizing: inherit;"><div><span style="font-size: 16px; color: rgb(51, 51, 51); font-family: &quot;Open Sans&quot;, &quot;Helvetica Neue&quot;, Helvetica, Roboto, Arial, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">在Excel、Prefab、ScriptableObject等不同载体上进行配置，更新配置就可以调用不同的代码逻辑分支</span></div></li><li style="box-sizing: inherit;"><div><span style="font-size: 16px; color: rgb(51, 51, 51); font-family: &quot;Open Sans&quot;, &quot;Helvetica Neue&quot;, Helvetica, Roboto, Arial, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; text-decoration: underline;">在语言里，内嵌一个解释器，下载下来的脚本语言，实际上只是按照不同的顺序，调用已经发布出去的代码，</span></div></li><ul style="box-sizing: inherit; list-style-type: disc; margin-bottom: 1em; padding-left: 28.8px;"><li style="box-sizing: inherit;"><div><span style="font-size: 16px; color: rgb(51, 51, 51); font-family: &quot;Open Sans&quot;, &quot;Helvetica Neue&quot;, Helvetica, Roboto, Arial, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">LUA</span></div></li><li style="box-sizing: inherit;"><div><span style="font-size: 16px; color: rgb(51, 51, 51); font-family: &quot;Open Sans&quot;, &quot;Helvetica Neue&quot;, Helvetica, Roboto, Arial, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">ILRuntime</span></div></li></ul></ul></ul><div><span style="font-size: 24pt; font-weight: bold;">ILRunTime</span></div></div><h3 style="font-size: 1.44em; margin: 0px 0px 1rem; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal;"><span style="font-size: 1.44em; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; color: rgb(51, 51, 51); font-family: &quot;Roboto Slab&quot;, &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; line-height: 1.8;">基本工作流程是怎么样的？</span></h3><ul style="list-style-type: disc; margin-bottom: 1em; padding-left: 28.8px; font-size: 16px; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal;"><li style="box-sizing: inherit;"><div><span style="font-size: 16px; color: rgb(51, 51, 51); font-family: &quot;Open Sans&quot;, &quot;Helvetica Neue&quot;, Helvetica, Roboto, Arial, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">启动游戏后，下载dll（CIL字节码），调用方法加载dll。</span></div></li><li style="box-sizing: inherit;"><div><span style="font-size: 16px; color: rgb(51, 51, 51); font-family: &quot;Open Sans&quot;, &quot;Helvetica Neue&quot;, Helvetica, Roboto, Arial, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">主工程可以用ILR提供的两种方式来调用热更代码：</span></div></li><ol style="box-sizing: inherit; list-style-type: decimal; margin-bottom: 14.4px; padding-left: 28.8px;"><li style="box-sizing: inherit;"><div><span style="font-size: 16px; color: rgb(51, 51, 51); font-family: &quot;Open Sans&quot;, &quot;Helvetica Neue&quot;, Helvetica, Roboto, Arial, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">appdomain.Invoke(“Hotfix.Game”, “Initialize”, null, null); 调用热更工程的静态方法</span></div></li><li style="box-sizing: inherit;"><div><span style="font-size: 16px; color: rgb(51, 51, 51); font-family: &quot;Open Sans&quot;, &quot;Helvetica Neue&quot;, Helvetica, Roboto, Arial, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">也可以用</span><a href="https://ourpalm.github.io/ILRuntime/public/v1/guide/reflection.html" style="font-size: 16px; color: rgb(41, 128, 185); font-family: &quot;Open Sans&quot;, &quot;Helvetica Neue&quot;, Helvetica, Roboto, Arial, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">反射</a><span style="font-size: 16px; color: rgb(51, 51, 51); font-family: &quot;Open Sans&quot;, &quot;Helvetica Neue&quot;, Helvetica, Roboto, Arial, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">创建热更中定义的类型的实例对象，并调用实例方法。</span></div></li></ol><li style="box-sizing: inherit;"><div><span style="font-size: 16px; color: rgb(51, 51, 51); font-family: &quot;Open Sans&quot;, &quot;Helvetica Neue&quot;, Helvetica, Roboto, Arial, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">热更工程则可以用正常的C#方式直接调用主工程的代码。</span></div></li></ul><h3 style="font-size: 1.44em; margin: 0px 0px 1rem; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal;"><span style="font-size: 1.44em; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; color: rgb(51, 51, 51); font-family: &quot;Roboto Slab&quot;, &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; line-height: 1.8;">主工程是怎么调用热更工程的代码的？</span></h3><ul><li><div><span style="font-size: 12pt;">在主工程的视角里,所有热更的类都是IType,方法是ILMethod,所有实例都是ILTypeInstance;需要用ILR框架提供的方式,调用实例方法,静态方法也有区别</span></div></li><li><div><span style="font-size: 12pt;">调用方法方式1:</span></div></li><ul><li><div>首先需要获取到目标类在主工程视角下的类型IType;Appdomian中保存了目标类名(FullName)为key的IType字典</div></li><li><div>其次获取IMethod,通过方法名从目标的Itype中获取</div></li><li><div>然后再调用 Appdomian.Invoke(IMethod m, object instance, params object[] p)</div></li></ul><li><div>调用静态方法可以使用上文方法,值得注意的是,静态方法不需要实例;也可以直接FullNameClass + MethodName 直接调用</div></li><li><div>调用实例方法前,需要new一个实例 appdomain.Instantiate(),然后使用方法1的步骤</div></li><li><div>或者使用InvocationContext(调用上下文)的方式,将实例,参数依次push进去</div></li><li><div>调用泛型方法,ref/out方法....</div></li></ul><h3 style="font-size: 1.44em; margin: 0px 0px 1rem; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal;"><span style="font-size: 1.44em; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; color: rgb(51, 51, 51); font-family: &quot;Roboto Slab&quot;, &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; line-height: 1.8;">热更工程代码为什么能调用主工程代码？</span></h3><ul style="list-style-type: disc; margin-bottom: 1em; padding-left: 28.8px; font-size: 16px; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal;"><li style="box-sizing: inherit;"><div><span style="font-size: 16px; color: rgb(51, 51, 51); font-family: &quot;Open Sans&quot;, &quot;Helvetica Neue&quot;, Helvetica, Roboto, Arial, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">一种是，解释器解释ILR代码后，最终通过反射调用指定的主工程代码 CLRMethod类里有MethodInfo会执行反射</span></div></li><li style="box-sizing: inherit;"><div><span style="font-size: 16px; color: rgb(51, 51, 51); font-family: &quot;Open Sans&quot;, &quot;Helvetica Neue&quot;, Helvetica, Roboto, Arial, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">另一种则是，所谓的</span><a href="https://ourpalm.github.io/ILRuntime/public/v1/guide/bind.html" style="font-size: 16px; color: rgb(41, 128, 185); font-family: &quot;Open Sans&quot;, &quot;Helvetica Neue&quot;, Helvetica, Roboto, Arial, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">CLR绑定</a><span style="font-size: 16px; color: rgb(51, 51, 51); font-family: &quot;Open Sans&quot;, &quot;Helvetica Neue&quot;, Helvetica, Roboto, Arial, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">的方式，就是对一些主工程经常被调用的方法生成绑定代码，绑定代码分为两部分，一部分在运行时提前用反射拿到要绑定方法的MethodBase，作为字典的key存下来，另一部分则是</span><span style="font-size: 16px; color: rgb(51, 51, 51); font-family: &quot;Open Sans&quot;, &quot;Helvetica Neue&quot;, Helvetica, Roboto, Arial, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; text-decoration: underline;">一个包装方法</span><span style="font-size: 16px; color: rgb(51, 51, 51); font-family: &quot;Open Sans&quot;, &quot;Helvetica Neue&quot;, Helvetica, Roboto, Arial, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">，内部调用了绑定方法，用ILR的方式处理参数和返回值，这个包装方法会作为字典的value存下来(绑定)。当ILR检测到热更代码要调用这些主工程代码的时候，</span><span style="font-size: 16px; color: rgb(51, 51, 51); font-family: &quot;Open Sans&quot;, &quot;Helvetica Neue&quot;, Helvetica, Roboto, Arial, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; text-decoration: underline;">就查找字典，改为调用包装方法(重定向)</span><span style="font-size: 16px; color: rgb(51, 51, 51); font-family: &quot;Open Sans&quot;, &quot;Helvetica Neue&quot;, Helvetica, Roboto, Arial, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">，从而避开反射的开销。</span></div></li><ul><li><div><span style="font-size: 12pt;"><span style="font-size: 12pt; color: rgb(51, 51, 51); font-family: &quot;Open Sans&quot;; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: bold;">个人看法: 重定向是发生在方法调用时(多次),绑定是初始化时(一次)</span></span></div></li></ul></ul><div><span style="font-size: 14pt;">跨域继承</span></div><div><span style="font-size: 12pt;">热更工程的类想要继承主工程的类或者接口,前提条件是在主工程上注册对应的Adapter. 因为在主工程的视角看来,热更工程的的类全是IType,</span></div><div><span style="font-size: 12pt;"><br/></span></div><div><span style="font-size: 12pt;">CLRType 和 ILType: 都是继承IType,CLRType是专门用于表示运行中实际调用的对象的类型信息,注册跨域继承时,实际上是Adapter的类型</span></div><div><span style="font-size: 12pt;"><br/></span></div><div><span style="font-size: 12pt;"><br/></span></div><div><span style="font-size: 12pt;">比较常见的情景:在热更工程上继承主工程类,并且调用主工程方法addList中,且调用派生类的方法;代码执行逻辑:</span></div><div><span style="font-size: 14pt;"><br/></span></div><div><span style="font-size: 14pt;"><br/></span></div><div>IlRuntime是字节码的解释器,不是JIT,也不是AOT,而是动态解释执行.net的字节码(虚拟机)</div><div>如何实现热更?</div><div>1.内置ILRunTime的解释器</div><div>2.从服务器下载.dll(.net字节码)</div><div>3.利用解释器解释执行.net字节码</div><div><br/></div><div>解释执行:C#底层运行的是IL代码,中间语言;它有自己的一套指令集,ILRuntime就是模仿指令集干活</div><div><br/></div><div style="margin: 1.4em 0px; font-size: medium; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255);"><span style="font-size: medium; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255); color: rgb(25, 27, 31); font-family: -apple-system, BlinkMacSystemFont, &quot;Helvetica Neue&quot;, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Source Han Sans SC&quot;, &quot;Noto Sans CJK SC&quot;, &quot;WenQuanYi Micro Hei&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">C#代码被编译器编译成公共语言CIL（也就是DLL），然后经过.netframework或者Mono转换成二进制的机器语言。也就是0101这种机器码。</span></div><div style="margin: 1.4em 0px; font-size: medium; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255);"><span style="font-size: medium; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; color: rgb(25, 27, 31); font-family: -apple-system, BlinkMacSystemFont, &quot;Helvetica Neue&quot;, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Source Han Sans SC&quot;, &quot;Noto Sans CJK SC&quot;, &quot;WenQuanYi Micro Hei&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">CIL中保存的是一些元信息（方法信息）和IL汇编信息（方法体及其中的机器指令）</span></div><div><br/></div><div>热加载的程序集和游戏程序集是相对独立的运行环境,因此两者之间的<span style="font-size: medium; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; color: rgb(25, 27, 31); font-family: -apple-system, BlinkMacSystemFont, &quot;Helvetica Neue&quot;, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Source Han Sans SC&quot;, &quot;Noto Sans CJK SC&quot;, &quot;WenQuanYi Micro Hei&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">数据和交互全靠ILRuntime在中间撮合。那撮合的方法就是实现一套适配的函数来实现每个每个函数的功能。</span></div><div><span style="color: rgb(25, 27, 31);"><img src="Evernote_files/Image.webp" type="image/webp" data-filename="Image.webp"/></span></div><div><span style="color: rgb(25, 27, 31);"><img src="Evernote_files/Image [1].webp" type="image/webp" data-filename="Image.webp"/></span></div><div><span style="font-size: medium; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; color: rgb(25, 27, 31); font-family: -apple-system, BlinkMacSystemFont, &quot;Helvetica Neue&quot;, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Source Han Sans SC&quot;, &quot;Noto Sans CJK SC&quot;, &quot;WenQuanYi Micro Hei&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">ILRuintime中的内存是非托管内存，内存的使用和释放完全是由ILRuntime自己来管理的。</span></div><div><span style="font-size: medium; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal;"><br/></span></div><div style="margin: 1.4em 0px; font-size: medium; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255);"><span style="font-size: medium; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255); color: rgb(25, 27, 31); font-family: -apple-system, BlinkMacSystemFont, &quot;Helvetica Neue&quot;, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Source Han Sans SC&quot;, &quot;Noto Sans CJK SC&quot;, &quot;WenQuanYi Micro Hei&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">项目在一开始就尽量减少MonoBehavior 的集成，MonoBehavior对热更会带来非常复杂和繁琐的功能。</span></div><div style="margin: 1.4em 0px; font-size: medium; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255);"><span style="font-size: medium; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255); color: rgb(25, 27, 31); font-family: -apple-system, BlinkMacSystemFont, &quot;Helvetica Neue&quot;, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Source Han Sans SC&quot;, &quot;Noto Sans CJK SC&quot;, &quot;WenQuanYi Micro Hei&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">热更域调用主域的的方法，比主域调用热更域效率高。</span></div><div style="margin: 1.4em 0px; font-size: medium; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255);"><span style="font-size: medium; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; color: rgb(25, 27, 31); font-family: -apple-system, BlinkMacSystemFont, &quot;Helvetica Neue&quot;, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Source Han Sans SC&quot;, &quot;Noto Sans CJK SC&quot;, &quot;WenQuanYi Micro Hei&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">最好的方式是将在脚本中获取GameObject,将生命周期和具体脚本逻辑隔离开来</span></div><div style="margin: 1.4em 0px; font-size: medium; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255);"><span style="font-size: medium; color: rgb(25, 27, 31); font-family: -apple-system, BlinkMacSystemFont, &quot;Helvetica Neue&quot;, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Source Han Sans SC&quot;, &quot;Noto Sans CJK SC&quot;, &quot;WenQuanYi Micro Hei&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;"><img src="Evernote_files/Image [2].webp" type="image/webp" data-filename="Image.webp"/></span></div><div style="margin: 1.4em 0px; font-size: medium; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255);"><span style="font-size: medium; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255); color: rgb(25, 27, 31); font-family: -apple-system, BlinkMacSystemFont, &quot;Helvetica Neue&quot;, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Source Han Sans SC&quot;, &quot;Noto Sans CJK SC&quot;, &quot;WenQuanYi Micro Hei&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">偏底层的部分放在主工程，偏框架方面的放主工程，经常使用而且修改可能性很小的部分放主工程。不能被热更的一些插件，SDK。对性能要求高的部分放在主工程</span></div><div style="margin: 1.4em 0px; font-size: medium; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255);"><span style="background-color: rgb(255, 255, 255); font-size: medium;"><span style="font-size: medium; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255); color: rgb(25, 27, 31); font-family: -apple-system, BlinkMacSystemFont, &quot;Helvetica Neue&quot;, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Source Han Sans SC&quot;, &quot;Noto Sans CJK SC&quot;, &quot;WenQuanYi Micro Hei&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">修改概率很高的部分，对性能要求不高的部分。放热更域。</span></span></div><div><br/></div><div>开发中的注意事项:</div><div>1.在热更工程中使用主工程的委托delegate,需要进行注册并且转换,ILRuntime内部是用Action和Func这两个系统内置的委托类型来创建实例的，所以其他的委托类型都需要写转换器;可见，用Action或者Func当作委托类型的话，可以避免写转换器，所以项目中在不必要的情况下尽量只用Action和Func</div><div><br/></div><div><br/></div></div><div><br/></div></span>
</div>
<hr>
<a name="596"/>

<div>
<span><div><span style="font-weight: bold; font-size: 18pt;">判空null</span></div><div><span style="font-size: 12pt;"><span style="font-size: 12pt; font-weight: bold;">两者不等价</span>,传统判空在多线程情况下还是有可能出现空异常:在判断委托不为空后,其他线程对原委托进行了置空操作</span></div><div><span style="font-size: 12pt;">在多线程中比较安全的写法是使用临时变量进行委托调用</span></div><div><span style="font-size: 12pt;"><b>?.null</b>运算符也是通过缓存目标对象到临时变量来达到线程安全的目的</span></div><div><span style="font-size: 12pt;">null ?.运算符是判断的是<u>对象地</u>址是否为空 </span><span style="font-family: 'JetBrains Mono',monospace; font-size: 12.0pt;background-color:rgb(38, 38, 38);color:rgb(208, 208, 208);">Object</span><span style="font-family: 'JetBrains Mono',monospace; font-size: 12.0pt; color: #bdbdbd;background-color:rgb(38, 38, 38);">.</span><span style="font-family: 'JetBrains Mono',monospace; font-size: 12.0pt;background-color:rgb(38, 38, 38);color:rgb(208, 208, 208);">ReferenceEquals</span><span style="font-family: 'JetBrains Mono',monospace; font-size: 12.0pt; color: #bdbdbd;background-color:rgb(38, 38, 38);">(</span><span style="font-family: 'JetBrains Mono',monospace; font-size: 12.0pt;background-color:rgb(38, 38, 38);color:rgb(208, 208, 208);">injectables</span><span style="font-family: 'JetBrains Mono',monospace; font-size: 12.0pt; color: #bdbdbd;background-color:rgb(38, 38, 38);">,</span> <span style="font-family: 'JetBrains Mono',monospace; font-size: 12.0pt; color: #6c95eb;background-color:rgb(38, 38, 38);">null</span><span style="font-family: 'JetBrains Mono',monospace; font-size: 12.0pt; color: #bdbdbd;background-color:rgb(38, 38, 38);">);</span><span style="font-size: 12pt;">  所以如果目标类重载的等号运算符<u>,?.是不会执行重载的判空逻辑</u><b>比如unity.object</b></span></div><div><span style="font-size: 18pt;"><span style="font-size: 18pt; font-weight: bold;"><img src="Evernote_files/Image [24].png" type="image/png" data-filename="Image.png"/></span></span></div><div><span style="font-size: 12pt; font-weight: bold;">unity.object的重载==运算符逻辑:</span></div><div><span style="font-size: 18pt;"><b><img src="Evernote_files/Image [25].png" type="image/png" data-filename="Image.png" width="1061"/></b></span></div></span>
</div>
<hr>
<a name="602"/>

<div>
<span><div><span style="font-size: 16pt; font-weight: bold;">游戏循环</span></div><div><span style="font-size: 24pt;"><span style="font-size: 24pt; font-weight: bold;">Unity </span></span><span style="font-size: 24pt;"><span style="font-size: 24pt; font-weight: bold;">monobehaviour 事件函数执行顺序</span></span></div><div><span style="font-size: 14pt;"><a href="https://blog.csdn.net/xiaoyaoACi/article/details/119324146" style="font-size: 14pt;">【Unity】Unity 生命周期-CSDN博客</a></span></div><div><img src="Evernote_files/dc9a9d51104b4a289f4c8c7c7762afb2.png" type="image/png" data-filename="dc9a9d51104b4a289f4c8c7c7762afb2.png"/>如果fixedTime的更新时间小于一帧时间;有可能会出现一帧进行多次物理逻辑更新</div><div>循环先后:物理更新--用户输入--逻辑更新--渲染</div><div><br/></div></span>
</div>
<hr>
<a name="604"/>

<div>
<span><div><br/></div><div>待做</div><div>四元数</div><div>内存优化</div><div>drawCall?如何减少</div><div>如何迁移Asset数据</div><div>UGUI如何屏幕自适应</div><div>C#反射原理</div></span>
</div>
<hr>
<a name="607"/>

<div>
<span><div><div>七层;物理层,数据链路层,协议层,传输层,会话层,表示层,应用层</div><div>TCP网络数据接收和发送</div><div>属于传输层</div><div>3次握手: 客户端向服务端发起请求;服务端-确认;客户端-确认服务端的确认</div><div><br/></div><div>TCP是面向连接的，UDP是无连接的</div><div>TCP是可靠的，UDP是不可靠的</div><div>TCP是面向字节流的，UDP是面向数据报文的</div><div>TCP只支持点对点通信，UDP支持一对一，一对多，多对多</div><div>TCP报文首部20个字节，UDP首部8个字节</div><div>TCP有拥塞控制机制，UDP没有</div><div>TCP协议下双方发送接受缓冲区都有</div><div><br/></div><div><br/></div><div>tcp粘包: tcp存在发送缓冲区,缓存区满了就会发送,由于数据包大小不固定可能会一次发送多个出现粘包;</div><div>拆包就是数据包大于缓存区需要分别多次发送</div><div><br/></div><div>如何解决? </div><ul><li><div>固定数据大小,会额外增加网络负担</div></li><li><div>自定义请求协议,消息头 + 消息体</div></li><li><div>特殊字符结尾</div></li></ul><div><br/></div></div><div><span style="font-weight: bold; color: rgb(0, 0, 0); font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; font-size: 12px; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal;">KCP基于UDP协议，在尽可能保留UDP快的前提下，借鉴了TCP的机制来保证可靠。KCP相比TCP浪费了10%~20%的带宽代价，换取了平均延迟降低30%~40%，且最大延迟降低三倍的传输效果。</span></div></span>
</div>
<hr>
<a name="609"/>

<div>
<span><div><div><div><span style="font-weight: bold; font-size: 24pt;">游戏技术</span></div><div><br/></div><div><br/></div><div>混合模式网络同步</div><ul><li><div>定时请求 + 时间戳序列号</div></li><li><div>初始化时服务端下发时间序列号</div></li><li><div>客户端每次同步时带上这个序列号,服务端回包会带上下次请求的序列号,客户端每次回包时更新该字段</div></li><li><div>服务端回包的是增量数据byte[] 和序列号;增量数据需要客户端自己解析成相应的协议类进行业务</div></li><li><div>强制同步机制:服务端主动推送增量包</div></li></ul><div>摄像机拖动限制</div></div><ul><li><div>获取两个线段的交点</div></li><ul><li><div>叉乘判断是否在同一个平面</div></li><li><div>快速排斥,判断是否存在重叠部分</div></li><li><div>跨立实验</div></li></ul><li><div>限制相机坐标</div></li></ul><div>动态网格</div><ul><li><div>相机坐标转化为逻辑坐标</div></li><li><div>逻辑坐标获取到当前区域id(10*10)为一个区;</div></li><li><div>调用网格系统生成网格,生成静态物体</div></li><li><div>请求以该区域为中心的9个区域数据</div></li><li><div>生成动态物体</div></li><li><div>拖动范围在一个区域不处理</div></li></ul><div>Promise数据驱动流程块</div><ul><li><div>IBlock:执行和终止,终止是使用序列号++</div></li><li><div>Flow:List&lt;IBlock&gt;,Promise.Sequence 所有的块</div></li></ul><div><br/></div><div>携程转异步</div><div><br/></div><div><br/></div><div><br/></div><div><br/></div><div><br/></div><div><br/></div><div><br/></div><div><br/></div></div><div><br/></div></span>
</div>
<hr>
<a name="611"/>

<div>
<span><div><div>分层时间轮</div><div><span style="font-size: 14px; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: pre-wrap; background-color: rgb(244, 246, 248); color: rgb(36, 41, 47); font-family: -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, &quot;Noto Sans&quot;, Helvetica, Arial, sans-serif, &quot;Apple Color Emoji&quot;, &quot;Segoe UI Emoji&quot;; font-variant-caps: normal; font-variant-ligatures: normal;">由多个轮组成，每个轮有多个槽位（slot）,每层槽位数量一致。每个槽位对应一段时间间隔，例如第一层的槽位代表 1 毫秒共10个,说明第一层时间轮大小为10毫秒;第二层每个槽位的大小刚好为第一层时间轮的大小,所以该层时间轮大小为100毫秒</span></div><ol><li><div><span style="font-size: 14px; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: pre-wrap; background-color: rgb(244, 246, 248); color: rgb(36, 41, 47); font-family: -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, &quot;Noto Sans&quot;, Helvetica, Arial, sans-serif, &quot;Apple Color Emoji&quot;, &quot;Segoe UI Emoji&quot;; font-variant-caps: normal; font-variant-ligatures: normal;">每经过tick时间,第一层就会前进一格,要是此时格子上存在任务时就会去执行;</span></div></li><li><div><span style="font-size: 11pt; color: rgb(36, 41, 47);">当第一层转完一圈之后,第二层就会前进一格,并将任务下放到第一层去;运行方式以此类推...</span></div></li></ol><div><span style="font-size: 11pt; color: rgb(36, 41, 47);">当槽位变多但是任务很少时,就会出现时间轮空转现象,如何优化?</span></div><ol><li><div><span style="font-size: 11pt; color: rgb(36, 41, 47);">使用延迟队列,对存在任务的槽位进行维护</span></div></li><li><div><span style="font-size: 11pt; color: rgb(36, 41, 47);">每个tick都去检查是否有时间槽到期了,存在的话就将时间槽推进到当前时间</span></div></li><li><div><span style="font-size: 11pt; color: rgb(36, 41, 47);">把槽里的任务取出执行</span></div></li><li><div><span style="font-size: 11pt; color: rgb(36, 41, 47);"> 指针前进存在任务下放的情况,需要重新计算任务的位置,把最新的时间槽添加到延迟队列里边</span></div></li></ol><div><br/></div></div></span>
</div>
<hr>
<a name="612"/>

<div>
<span><div>unity 内置渲染管线</div><div><img src="Evernote_files/Image [26].png" type="image/png" data-filename="Image.png"/></div><div><img src="Evernote_files/Image [27].png" type="image/png" data-filename="Image.png"/></div><div><br/></div></span>
</div>
<hr>
<a name="615"/>

<div>
<span><div><div>Inject Fix</div><h3 style="margin: 10px 0px; padding: 0px; letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255); font-size: 19px !important;"><span style="letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; font-size: 19px; color: rgb(49, 70, 89); font-family: Lato, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: bold; line-height: 1.5;">一、原理:</span></h3><div style="margin: 0px; padding: 0px; font-size: 16px; letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255);"><span style="font-size: 16px; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; color: rgb(49, 70, 89); font-family: Lato, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">虚拟机负责新逻辑的解析执行；注入代码负责把调用重定向到虚拟机；</span></div><div style="margin: 0px; padding: 0px; font-size: 16px; letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255);"><span style="font-size: 16px; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; color: rgb(49, 70, 89); font-family: Lato, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">和ILRunTime的区别:</span><span style="color: rgb(49, 70, 89); font-family: Lato, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, sans-serif; font-size: 16px; font-variant-caps: normal; font-variant-ligatures: normal;"> </span><span style="font-size: 16px; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; color: rgb(77, 77, 77); font-family: -apple-system, &quot;SF UI Text&quot;, Arial, &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, &quot;WenQuanYi Micro Hei&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: no-common-ligatures;">打补丁后需要修复的部分才局部重定向到IL虚拟机解释执行。（ILRutime是全程解释执行C#编译后的dll，Lua本身就是解释型语言）</span></div><div style="margin: 0px; padding: 0px; font-size: 16px; letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255);"><span style="font-size: 16px; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; color: rgba(0, 0, 0, 0.75); font-family: -apple-system, &quot;SF UI Text&quot;, Arial, &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, &quot;WenQuanYi Micro Hei&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: no-common-ligatures;">特点:接入简单，侵入性小</span></div><div style="position: relative; text-align: left;"><h1><span style="font-weight: bold;">使用注意事项：</span></h1></div><div style="position: relative; text-align: left;"><div style="margin-top: 1em; margin-bottom: 1em;"><span style="-en-paragraph:true;">1. 构造函数不支持Patch</span></div></div><div style="position: relative; text-align: left;"><div style="margin-top: 1em; margin-bottom: 1em;"><span style="-en-paragraph:true;">2. 新增方法用Interpret，不支持新增方法override父类。</span></div></div><div style="position: relative; text-align: left;"><div style="margin-top: 1em; margin-bottom: 1em;"><span style="-en-paragraph:true;">3.</span> <span style="font-weight: bold;-en-paragraph:true;">async/await不支持</span></div><div style="margin-top: 1em; margin-bottom: 1em;"><b><span style="-en-paragraph:true;">Linq 不可用</span></b><br/></div></div><div style="position: relative; text-align: left;"><div style="margin-top: 1em; margin-bottom: 1em;"><span style="-en-paragraph:true;">4. 不支持新增成员变量</span></div></div><div style="position: relative; text-align: left;"><div style="margin-top: 1em; margin-bottom: 1em;"><span style="-en-paragraph:true;">5. 泛型不支持注入</span></div></div><div style="position: relative; text-align: left;"><div style="margin-top: 1em; margin-bottom: 1em;"><span style="-en-paragraph:true;">6. 之前未使用的泛型不能使用， 某些泛型没法动态实例化，il2cpp不支持jit。如果你之前没用过这个泛型，unity不会编译进发布包。则运行时没有这个泛型。</span></div></div><div style="position: relative; text-align: left;"><div style="margin-top: 1em; margin-bottom: 1em;"><span style="-en-paragraph:true;">7. MonoBehaviour的EventFunction 不支持新增注入</span></div></div><div style="position: relative; text-align: left;"><div style="margin-top: 1em; margin-bottom: 1em;"><span style="-en-paragraph:true;">8. 被override 的函数如果泛型的话，不支持。</span></div></div><div style="position: relative; text-align: left;"><div style="margin-top: 1em; margin-bottom: 1em;"><span style="-en-paragraph:true;">9. int[] temp = new int[] { 1,2,3};这种需要写成 int a = 1；int b = 2；int c = 3;</span></div></div><div style="position: relative; text-align: left;"><div style="margin-top: 1em; margin-bottom: 1em;"><span style="-en-paragraph:true;">int[] temp = new int[] { a,b,c};</span></div></div><div style="position: relative; text-align: left;"><div style="margin-top: 1em; margin-bottom: 1em;"><span style="-en-paragraph:true;">10. LogError：not support il[IL_0060: ldtoken &lt;PrivateImplementationDetails&gt;/ __StaticArrayInitTypeSize=12</span></div></div><div style="position: relative; text-align: left;"><div style="margin-top: 1em; margin-bottom: 1em;"><span style="-en-paragraph:true;">11. Sort 不行， list.Find(不支持）</span></div></div><div style="position: relative; text-align: left;"><div style="margin-top: 1em; margin-bottom: 1em;"><span style="-en-paragraph:true;">12. 新增方法用Interpret，不支持新增方法override父类。</span></div></div><div style="position: relative; text-align: left;"><div style="margin-top: 1em; margin-bottom: 1em;"><span style="-en-paragraph:true;">13. MGTask 新增</span></div></div><ol style="counter-reset: ordered-0 13 ordered-1 0 ordered-2 0 ordered-3 0 ordered-4 0 ordered-5 0 ordered-6 0 ordered-7 0 ordered-8 0 ordered-9 0 ordered-10 0; text-align: left;"><li><div>最新版本的InjectFix，好像不能out结构体，我们2020年4月1日的版本版本没有问题。</div></li></ol><div style="position: relative; text-align: left;"><div style="margin-top: 1em; margin-bottom: 1em;"><span style="-en-paragraph:true;">15. ？语法糖</span></div></div><div style="position: relative; text-align: left;"><div style="margin-top: 1em; margin-bottom: 1em;"><span style="-en-paragraph:true;">16. Get set</span></div></div><div style="position: relative; text-align: left;"><div style="margin-top: 1em; margin-bottom: 1em;"><span style="-en-paragraph:true;">17.</span> <span style="text-decoration: line-through;-en-paragraph:true;">（）=&gt;{}</span> <span style="-en-paragraph:true;">已验证，匿名委托可以支持 [IFix.Patch]</span></div></div><div style="position: relative; text-align: left;"><div style="margin-top: 1em; margin-bottom: 1em;"><span style="-en-paragraph:true;">18. 扩展方法exten List.Foreach()</span></div></div><div style="position: relative; text-align: left;"><div style="margin-top: 1em; margin-bottom: 1em;"><span style="-en-paragraph:true;">19. initActorsAsyncCoroutine</span></div></div><div style="position: relative; text-align: left;"><div style="margin-top: 1em; margin-bottom: 1em;"><span style="-en-paragraph:true;">20. Promise</span></div></div><div style="position: relative; text-align: left;"><div style="margin-top: 1em; margin-bottom: 1em;"><span style="-en-paragraph:true;">21. GetComponent&lt;TextEx&gt;()</span></div></div><div style="position: relative; text-align: left;"><div style="margin-top: 1em; margin-bottom: 1em;"><span style="-en-paragraph:true;">22. 自己的方法泛型。 没合适的方法</span></div></div><div style="position: relative; text-align: left;"><div style="margin-top: 1em; margin-bottom: 1em;"><span style="-en-paragraph:true;">23. 类的真泛型（&lt;T&gt;）不支持</span></div></div><div style="position: relative; text-align: left;"><div style="margin-top: 1em; margin-bottom: 1em;"><span style="-en-paragraph:true;">24. Linq 不可用</span></div></div><div style="position: relative; text-align: left;"><div style="margin-top: 1em; margin-bottom: 1em;"><span style="-en-paragraph:true;">25. Thread 线程内代码 rvo 未加入命名空间 可以</span></div></div><div style="position: relative; text-align: left;"><div style="margin-top: 1em; margin-bottom: 1em;"><span style="-en-paragraph:true;">26. HotFix调用的方法被注入（待确认）没找到合适的方法</span></div></div><div style="position: relative; text-align: left;"><div style="margin-top: 1em; margin-bottom: 1em;"><span style="-en-paragraph:true;">27. Hotfix ： override void _onShowWnd()不能注入</span></div></div><div style="position: relative; text-align: left;"><div style="margin-top: 1em; margin-bottom: 1em;"><span style="-en-paragraph:true;">28.泛型类的函</span><span style="text-decoration: line-through;-en-paragraph:true;">数</span><span style="-en-paragraph:true;">不支持注入</span></div></div><div style="position: relative; text-align: left;"><div style="width: 470px;"><div style="height: auto;"><img src="Evernote_files/Image [28].png" type="image/png" data-filename="Image.png"/></div></div></div><div style="position: relative; text-align: left;"><div style="margin-top: 1em; margin-bottom: 1em;"><span style="-en-paragraph:true;">29. 泛型函数不支持注入</span></div></div><div style="position: relative; text-align: left;"><div style="width: 238px;"><div style="height: auto;"><img src="Evernote_files/Image [29].png" type="image/png" data-filename="Image.png"/></div></div></div><div style="position: relative; text-align: left;"><div style="margin-top: 1em; margin-bottom: 1em;"><span style="-en-paragraph:true;">30.1. 继承自泛型，但确定了实现的类支持注入，如图</span></div></div><div style="position: relative; text-align: left;"><div style="width: 593px;"><div style="height: auto;"><img src="Evernote_files/Image [30].png" type="image/png" data-filename="Image.png"/></div></div></div><div style="position: relative; text-align: left;"><div style="margin-top: 1em; margin-bottom: 1em;"><span style="-en-paragraph:true;">31.不能给字典的tryGetValue()方法不支持注入</span></div></div><div style="margin: 0px; padding: 0px; font-size: 16px; letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255);"><div style="margin-top: 1em; margin-bottom: 1em;"><span style="color: rgb(49, 70, 89); font-family: Lato, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, sans-serif; font-size: 16px; font-variant-caps: normal; font-variant-ligatures: normal;-en-paragraph:true;">32.MGGame的enterUIMainNodeShow方法不能IF</span></div><div><br/></div></div><div><br/></div></div><div><br/></div></span>
</div>
<hr>
<a name="620"/>

<div>
<span><div><div><span style="font-size: 16pt; font-weight: bold;">Promise</span></div><div>是异步编程的一种解决方案,有效减少回调嵌套;<span style="font-weight: bold;">支持链式调用,解决回调地狱问题(面试必问)</span></div><ul><li><div><span style="font-weight: bold;">代码嵌套bad: 在复杂的业务逻辑中,不便于异常的处理以及阅读</span></div></li></ul><div><span style="font-weight: bold;">把嵌套的写法改成顺序写法--promise提供链式调用</span></div><div><span style="box-sizing: border-box; outline: 0px; --el-button-hover-bg-color: #6D5FFD; --el-button-hover-border-color: #6D5FFD; --el-button-active-bg-color: #6D5FFD; --el-button-active-border-color: #6D5FFD; overflow-wrap: break-word; font-size: 16px; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(238, 240, 244); color: rgb(79, 79, 79); font-family: -apple-system, &quot;SF UI Text&quot;, Arial, &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, &quot;WenQuanYi Micro Hei&quot;, sans-serif, SimHei, SimSun; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: bold;">then方法返回的是一个新的</span><span style="box-sizing: border-box; outline: 0px; overflow-wrap: break-word; font-size: 16px; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(238, 240, 244); color: rgb(79, 79, 79); font-family: -apple-system, &quot;SF UI Text&quot;, Arial, &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, &quot;WenQuanYi Micro Hei&quot;, sans-serif, SimHei, SimSun; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: bold;">Promise实例（注意，不是原来那个Promise实例）。因此可以采用链式写法，即then方法后面再调用另一个then方法</span><span style="font-size: 16px; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(238, 240, 244); color: rgb(79, 79, 79); font-family: -apple-system, &quot;SF UI Text&quot;, Arial, &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, &quot;WenQuanYi Micro Hei&quot;, sans-serif, SimHei, SimSun; font-variant-caps: normal; font-variant-ligatures: normal;">。</span></div></div><div style="box-sizing: border-box; padding: 8px; font-family: Monaco, Menlo, Consolas, &quot;Courier New&quot;, monospace; font-size: 12px; color: rgb(51, 51, 51); border-radius: 4px; background-color: rgb(251, 250, 248); border: 1px solid rgba(0, 0, 0, 0.15);-en-codeblock:true;"><div>public IPromise Then(Action onResolved, Action&lt;Exception&gt; onRejected, Action&lt;float&gt; onProgress)</div><div>{</div><div>    Promise resultPromise = new Promise();</div><div>    resultPromise.WithName(Name);</div><div>    //解决回调</div><div>    Action resolveHandler = () =&gt;</div><div>    {</div><div>        if (onResolved != null)</div><div>        {</div><div>            onResolved();</div><div>        }</div><div>        //执行下一个promise的解决</div><div>        resultPromise.Resolve();</div><div>    };</div><div>    //拒绝回调</div><div>    Action&lt;Exception&gt; rejectHandler = ex =&gt;</div><div>    {</div><div>        if (onRejected != null)</div><div>        {</div><div>            onRejected(ex);</div><div>            resultPromise.Resolve();</div><div>            return;</div><div>        }</div><div>        //执行下一个promise的拒绝</div><div>        resultPromise.Reject(ex);</div><div>    };</div><div>    //立刻调用/注册回调</div><div>    ActionHandlers(resultPromise, resolveHandler, rejectHandler);</div><div>    //注册进度回调</div><div>    if (onProgress != null)</div><div>    {</div><div>        ProgressHandlers(this, onProgress);</div><div>    }</div><div>    return resultPromise;</div><div>}</div></div><div>代码如何链式执行?</div><div>每个Promise存储两个回调列表(解决,拒绝),每次执行Resolve/Reject都会执行对应的回调列表里的方法,然后调用下一个Peomise的Resolve;Then方法每次调用时会创建一个Promise,这个实例就是下一次执行类</div><div>Then也可以传入Func&lt;IPromise&gt;,将Promise控制权抛出</div><div>ThenAll的实现方式就是记录Promise个数,所有Promise都实现总promise才视为实现</div><div>Sequence的实现使用到了Linq的 <span style="color: rgb(255, 0, 0); font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; font-size: 13.3333px; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(253, 253, 223);"> Aggregate</span> 累加器,将所有Promise用Then连起来</div></span>
</div>
<hr>
<a name="621"/>

<div>
<span><div><div><div><div><div>资源加载-AssetBundle</div><div>ab包是什么:特定<span style="font-weight: bold;">于平台</span>的<span style="font-weight: bold;">资产压缩包(不同平台需要不同的压缩包)</span>,类是于压缩文件,资产包括:模型,贴图,预设体,音效,材质球<span style="font-weight: bold;">场景</span>等</div><div>为什么需要使用ab包?</div><ol><li><div>减少初始安装大小</div></li><li><div>减少游戏运行时的内存压力</div></li><li><div>方便管理可下载内容</div></li><li><div>方便游戏版本管理</div></li></ol><div><br/></div><ul><li><div>ab的组成</div></li><ul><li><div>资源文件,二进制数据块</div></li></ul><li><div>构建AB包</div></li><ul><li><div>BuildPipeline.BuildAssetBundles( 构建编辑器中指定的所有 AssetBundle)</div></li><ul><li><div>ab输出路径</div></li><li><div>BuildAssetBundleOptions(构建选项)</div></li><ul><li><div>None: LZMA压缩(流压缩),(压缩包更小,加载时间更长)使用之前需要解压;解压完这个包又会被Lz4压缩.使用资源的时候不需要整体解压. 。在下载的时候可以使用LZMA算法，一旦它被下载了之后，它会使用LZ4算法保存到本地上。</div></li><li><div>UncompressedAssetBundle：不压缩，包大，加载快</div></li><li><div>ChunkBasedCompression: 使用LZ4压缩(块压缩)，压缩率没有LZMA高，但是我们可以加载指定资源而不用解压全部。</div></li></ul><li><div><a href="https://docs.unity3d.com/cn/2021.3/ScriptReference/BuildTarget.html">BuildTarget</a>(目标构建平台)</div></li></ul></ul></ul><div><img src="Evernote_files/Image [31].png" type="image/png" data-filename="Image.png"/></div><hr/><div><br/></div><div>1. Unity AssetBundle的压缩格式对比</div><div>Unity的AssetBundle支持多种压缩格式，常见的包括：</div><div><br/></div><div>1.1 Uncompressed（无压缩）</div><div>无压缩的AssetBundle不会对资源进行任何压缩，适用于对加载速度有极高要求的场景。其优点是加载速度最快，但缺点是文件体积大，网络传输成本高。</div><div><br/></div><div>1.2 <span style="font-weight: bold;">LZMA</span>（高压缩率，慢解压）</div><div>LZMA（Lempel-Ziv-Markov chain Algorithm）是一种高效的压缩算法，可以大幅减少AssetBundle的体积。其特点包括：</div><div><br/></div><div><span style="font-weight: bold;">压缩率高</span>：能有效减少下载流量和存储占用。</div><div><br/></div><div><span style="font-weight: bold;">解压慢</span>：LZMA在运行时需要解压到内存后才能使用，会导致较高的RAM占用峰值，尤其是对于大资源包来说影响明显。</div><div><br/></div><div><span style="font-weight: bold;">适用于CDN分发</span>：由于压缩率高，LZMA格式适合用于在线分发，但需要下载后进行转换。</div><div><span style="font-size: 12pt;"><br/></span></div><div>1.3 <span style="font-weight: bold;">LZ4</span>（快速解压，低内存消耗）</div><div>LZ4是一种轻量级压缩算法，专门为快速解压设计。其特点包括：</div><div><br/></div><div><span style="font-weight: bold;">解压速度快</span>：相比LZMA，LZ4的解压过程几乎可以忽略不计。</div><div><br/></div><div><span style="font-weight: bold;">适合游戏运行时使用</span>：LZ4格式的AssetBundle可以直接从磁盘流式加载，减少对RAM的消耗。</div><div><br/></div><div><span style="font-weight: bold;">压缩率低</span>：LZ4的压缩率比LZMA低，文件体积相对较大。</div><div><br/></div><div><span style="font-size: 16px; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; color: rgb(77, 77, 77); font-family: -apple-system, &quot;SF UI Text&quot;, Arial, &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, &quot;WenQuanYi Micro Hei&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: no-common-ligatures; text-decoration: underline;">LZMA是一个整体打成压缩包。LZ4是每个文件单独再打成压缩包再放在一起。所以加载LZ4的时候，AssetBundle只是一个引用，可以单独的提取LZ4压缩包里面的个别文件来使用。</span> <span style="font-size: 16px; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; color: rgb(77, 77, 77); font-family: -apple-system, &quot;SF UI Text&quot;, Arial, &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, &quot;WenQuanYi Micro Hei&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: no-common-ligatures; text-decoration: underline;">而LZMA作为一个整体，必须一起加载到内存里面去。LZMA加载完之后，是会解压缩然后再次打包成LZ4的格式存在于内存里面，然后再加载的。</span></div><div><br/></div><div>1.4 选择合适的压缩格式</div><div>根据不同需求，可以选择不同的压缩格式：</div><div><br/></div><div>在线分发（CDN下载）：LZMA</div><div><br/></div><div><span style="font-weight: bold;">本地存储及游戏运行时加载：LZ4</span></div><div><br/></div><div>对加载速度极端敏感的资源：Uncompressed</div><div><br/></div><h4 style="box-sizing: border-box; outline: 0px; margin: 24px 0px 8px; padding: 0px; font-size: 18px; overflow-wrap: break-word; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255);"><span style="box-sizing: border-box; outline: 0px; font-size: 18px; overflow-wrap: break-word; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; color: rgb(79, 79, 79); font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, SimHei, Arial, SimSun; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: bold; line-height: 26px;">优化前的问题</span></h4><div>直接使用LZMA格式的AssetBundle，在加载时需要解压到内存，占用大量RAM。<span style="font-size: unset; color: unset; font-family: unset;">当多个大型AssetBundle同时加载时，容易触发内存峰值，甚至导致崩溃。</span></div><div><br/></div><div><font style="font-size: 12pt;"><span style="font-size: 12pt; font-weight: bold; text-decoration: underline;">1.5 优化方案</span></font></div><div><span style="font-size: 12pt;">下载assetbundle(lzma格式)</span></div><div><span style="font-size: 12pt;">将lzma格式转化为lz4 使用 </span><span style="box-sizing: border-box; outline: 0px; border-radius: 4px; overflow-wrap: break-word; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; font-size: 12pt; color: rgb(77, 77, 77); font-variant-caps: normal; font-variant-ligatures: normal;">AssetBundle.<span style="font-size: 12pt; color: rgb(77, 77, 77); font-variant-caps: normal; font-variant-ligatures: normal; font-weight: bold;">RecompressAssetBundleAsync</span></span><span style="letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255);"><span style="font-size: 12pt; background-color: rgb(255, 255, 255); color: rgb(77, 77, 77); font-family: -apple-system, &quot;SF UI Text&quot;, Arial, &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, &quot;WenQuanYi Micro Hei&quot;, sans-serif, SimHei, SimSun; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: bold;"> </span></span><span style="letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; font-size: 12pt; color: rgb(77, 77, 77); font-family: -apple-system, &quot;SF UI Text&quot;, Arial, &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, &quot;WenQuanYi Micro Hei&quot;, sans-serif, SimHei, SimSun; font-variant-caps: normal; font-variant-ligatures: normal;">接口</span></div><div><font style="font-size: 12pt;"><span style="box-sizing: border-box; outline: 0px; overflow-wrap: break-word; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255); font-size: 12pt; color: rgb(77, 77, 77); font-family: -apple-system, &quot;SF UI Text&quot;, Arial, &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, &quot;WenQuanYi Micro Hei&quot;, sans-serif, SimHei, SimSun; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: bold;">存储LZ4格式的AssetBundle</span><span style="letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; font-size: 12pt; color: rgb(77, 77, 77); font-family: -apple-system, &quot;SF UI Text&quot;, Arial, &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, &quot;WenQuanYi Micro Hei&quot;, sans-serif, SimHei, SimSun; font-variant-caps: normal; font-variant-ligatures: normal;">，下次加载时直接使用</span></font></div><div style="box-sizing: border-box; padding: 8px; font-family: Monaco, Menlo, Consolas, &quot;Courier New&quot;, monospace; font-size: 12px; color: rgb(51, 51, 51); border-radius: 4px; background-color: rgb(251, 250, 248); border: 1px solid rgba(0, 0, 0, 0.15);-en-codeblock:true;"><div>public async void ConvertLZMAToLZ4(string inputPath, string outputPath)</div><div>    {</div><div>        if (!File.Exists(inputPath))</div><div>        {</div><div>            Debug.LogError(&quot;Source AssetBundle not found: &quot; + inputPath);</div><div>            return;</div><div>        }</div><div>        using (var inputStream = File.OpenRead(inputPath))</div><div>        using (var outputStream = File.Create(outputPath))</div><div>        {</div><div>            var result = await AssetBundle.RecompressAssetBundleAsync(inputStream, outputStream,</div><div>                BuildCompression.LZ4Runtime);</div><div>            if (result.success)</div><div>            {</div><div>                Debug.Log(&quot;AssetBundle successfully converted to LZ4: &quot; + outputPath);</div><div>            }</div><div>            else</div><div>            {</div><div>                Debug.LogError(&quot;Failed to convert AssetBundle&quot;);</div><div>            }</div><div>        }</div><div>    }</div></div><h4 style="box-sizing: border-box; outline: 0px; margin: 24px 0px 8px; padding: 0px; font-size: 18px; overflow-wrap: break-word; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal;"><br/></h4><hr/><div style="box-sizing: border-box; outline: 0px; margin: 24px 0px 8px; padding: 0px; overflow-wrap: break-word; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal;"><span style="letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: pre-wrap; background-color: rgb(239, 246, 255);"><span style="background-color: rgb(239, 246, 255); font-size: 18pt; color: rgb(38, 38, 38); font-family: quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Noto Sans&quot;, Ubuntu, Cantarell, &quot;Helvetica Neue&quot;, Oxygen, &quot;Open Sans&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: bold;">依赖拆分策略</span></span></div><div style="margin: 13.716px 0px; font-size: 16.002px; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255);"><span style="font-size: 16.002px; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255); color: rgb(64, 64, 64); font-family: quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Noto Sans&quot;, Ubuntu, Cantarell, &quot;Helvetica Neue&quot;, Oxygen, &quot;Open Sans&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; line-height: 28.575px;">当资源A（如Prefab）引用资源B（如材质/贴图）时：</span></div><ol start="1" style="margin: 13.716px 0px; padding-left: 27.432px; font-size: 16.002px; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255);"><li><div style="margin-top: 0px; margin-right: 0px; margin-left: 0px; font-size: 16.002px; margin-bottom: 0px !important;"><span style="font-size: 16.002px; color: rgb(64, 64, 64); font-family: quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Noto Sans&quot;, Ubuntu, Cantarell, &quot;Helvetica Neue&quot;, Oxygen, &quot;Open Sans&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; line-height: 28.575px;">若A、B在不同AssetBundle中 → 加载A需</span><span style="font-size: 16.002px; color: rgb(64, 64, 64); font-family: quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Noto Sans&quot;, Ubuntu, Cantarell, &quot;Helvetica Neue&quot;, Oxygen, &quot;Open Sans&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: bold; line-height: 28.575px;">先加载B所在的AB包</span></div></li><li style="margin-top: 4px;"><div style="margin-top: 0px; margin-right: 0px; margin-left: 0px; font-size: 16.002px; margin-bottom: 0px !important;"><span style="font-size: 16.002px; color: rgb(64, 64, 64); font-family: quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Noto Sans&quot;, Ubuntu, Cantarell, &quot;Helvetica Neue&quot;, Oxygen, &quot;Open Sans&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; line-height: 28.575px;">若未提前加载依赖包 → 资源引用丢失（粉色缺失状态）</span></div></li></ol><div style="box-sizing: border-box; outline: 0px; margin: 24px 0px 8px; padding: 0px; font-size: 18px; overflow-wrap: break-word; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal;"></div><h3 style="font-size: 18.288px; margin: 18.288px 0px 13.716px; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255);"><span style="font-size: 18.288px; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255); color: rgb(64, 64, 64); font-family: quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Noto Sans&quot;, Ubuntu, Cantarell, &quot;Helvetica Neue&quot;, Oxygen, &quot;Open Sans&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: bold; line-height: 1.5;">依赖拆分黄金法则</span></h3><ol start="1" style="margin: 13.716px 0px; padding-left: 27.432px; font-size: 16.002px; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255);"><li><div style="margin-top: 0px; margin-right: 0px; margin-left: 0px; font-size: 16.002px; margin-bottom: 0px !important;"><span style="font-size: 16.002px; color: rgb(64, 64, 64); font-family: quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Noto Sans&quot;, Ubuntu, Cantarell, &quot;Helvetica Neue&quot;, Oxygen, &quot;Open Sans&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: bold; line-height: 28.575px;">高复用资源抽离</span><span style="font-size: 16.002px; color: rgb(64, 64, 64); font-family: quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Noto Sans&quot;, Ubuntu, Cantarell, &quot;Helvetica Neue&quot;, Oxygen, &quot;Open Sans&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; line-height: 28.575px;"> </span><span style="font-size: 16.002px; color: rgb(64, 64, 64); font-family: quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Noto Sans&quot;, Ubuntu, Cantarell, &quot;Helvetica Neue&quot;, Oxygen, &quot;Open Sans&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; line-height: 28.575px;">→ 共享包</span></div></li><li style="margin-top: 4px;"><div style="margin-top: 0px; margin-right: 0px; margin-left: 0px; font-size: 16.002px; margin-bottom: 0px !important;"><span style="font-size: 16.002px; color: rgb(64, 64, 64); font-family: quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Noto Sans&quot;, Ubuntu, Cantarell, &quot;Helvetica Neue&quot;, Oxygen, &quot;Open Sans&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: bold; line-height: 28.575px;">功能内聚优先</span><span style="font-size: 16.002px; color: rgb(64, 64, 64); font-family: quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Noto Sans&quot;, Ubuntu, Cantarell, &quot;Helvetica Neue&quot;, Oxygen, &quot;Open Sans&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; line-height: 28.575px;"> </span><span style="font-size: 16.002px; color: rgb(64, 64, 64); font-family: quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Noto Sans&quot;, Ubuntu, Cantarell, &quot;Helvetica Neue&quot;, Oxygen, &quot;Open Sans&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; line-height: 28.575px;">→ 按模块/场景分组</span></div></li><li style="margin-top: 4px;"><div style="margin-top: 0px; margin-right: 0px; margin-left: 0px; font-size: 16.002px; margin-bottom: 0px !important;"><span style="font-size: 16.002px; color: rgb(64, 64, 64); font-family: quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Noto Sans&quot;, Ubuntu, Cantarell, &quot;Helvetica Neue&quot;, Oxygen, &quot;Open Sans&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: bold; line-height: 28.575px;">层级扁平化</span><span style="font-size: 16.002px; color: rgb(64, 64, 64); font-family: quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Noto Sans&quot;, Ubuntu, Cantarell, &quot;Helvetica Neue&quot;, Oxygen, &quot;Open Sans&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; line-height: 28.575px;"> </span><span style="font-size: 16.002px; color: rgb(64, 64, 64); font-family: quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Noto Sans&quot;, Ubuntu, Cantarell, &quot;Helvetica Neue&quot;, Oxygen, &quot;Open Sans&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; line-height: 28.575px;">→ 依赖链不超过3层</span></div></li><li style="margin-top: 4px;"><div style="margin-top: 0px; margin-right: 0px; margin-left: 0px; font-size: 16.002px; margin-bottom: 0px !important;"><span style="font-size: 16.002px; color: rgb(64, 64, 64); font-family: quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Noto Sans&quot;, Ubuntu, Cantarell, &quot;Helvetica Neue&quot;, Oxygen, &quot;Open Sans&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: bold; line-height: 28.575px;">生命周期对齐</span><span style="font-size: 16.002px; color: rgb(64, 64, 64); font-family: quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Noto Sans&quot;, Ubuntu, Cantarell, &quot;Helvetica Neue&quot;, Oxygen, &quot;Open Sans&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; line-height: 28.575px;"> </span><span style="font-size: 16.002px; color: rgb(64, 64, 64); font-family: quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Noto Sans&quot;, Ubuntu, Cantarell, &quot;Helvetica Neue&quot;, Oxygen, &quot;Open Sans&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; line-height: 28.575px;">→ 同一使用节奏的资源打同一包</span></div></li><li style="margin-top: 4px;"><div style="margin-top: 0px; margin-right: 0px; margin-left: 0px; font-size: 16.002px; margin-bottom: 0px !important;"><span style="font-size: 16.002px; color: rgb(64, 64, 64); font-family: quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Noto Sans&quot;, Ubuntu, Cantarell, &quot;Helvetica Neue&quot;, Oxygen, &quot;Open Sans&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: bold; line-height: 28.575px;">用工具监控</span><span style="font-size: 16.002px; color: rgb(64, 64, 64); font-family: quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Noto Sans&quot;, Ubuntu, Cantarell, &quot;Helvetica Neue&quot;, Oxygen, &quot;Open Sans&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; line-height: 28.575px;"> </span><span style="font-size: 16.002px; color: rgb(64, 64, 64); font-family: quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Noto Sans&quot;, Ubuntu, Cantarell, &quot;Helvetica Neue&quot;, Oxygen, &quot;Open Sans&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; line-height: 28.575px;">→ 依赖环 &amp; 冗余检测</span></div></li></ol><div style="box-sizing: border-box; outline: 0px; margin: 24px 0px 8px; padding: 0px; font-size: 18px; overflow-wrap: break-word; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal;"><span style="font-size: 16.002px; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; color: rgb(64, 64, 64); font-family: quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Noto Sans&quot;, Ubuntu, Cantarell, &quot;Helvetica Neue&quot;, Oxygen, &quot;Open Sans&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">AB包拆分不是越细越好，需在</span><span style="font-size: 16.002px; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255); color: rgb(64, 64, 64); font-family: quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Noto Sans&quot;, Ubuntu, Cantarell, &quot;Helvetica Neue&quot;, Oxygen, &quot;Open Sans&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: bold;">资源复用率、加载速度、内存开销、网络效率</span><span style="font-size: 16.002px; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255); color: rgb(64, 64, 64); font-family: quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Noto Sans&quot;, Ubuntu, Cantarell, &quot;Helvetica Neue&quot;, Oxygen, &quot;Open Sans&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">之间寻找平衡点。过度拆分将导致“</span><span style="font-size: 16.002px; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255); color: rgb(64, 64, 64); font-family: quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Noto Sans&quot;, Ubuntu, Cantarell, &quot;Helvetica Neue&quot;, Oxygen, &quot;Open Sans&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: bold;">空间+时间+内存</span><span style="font-size: 16.002px; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; color: rgb(64, 64, 64); font-family: quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Noto Sans&quot;, Ubuntu, Cantarell, &quot;Helvetica Neue&quot;, Oxygen, &quot;Open Sans&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">”三重惩罚！</span></div><div style="box-sizing: border-box; outline: 0px; margin: 24px 0px 8px; padding: 0px; font-size: 18px; overflow-wrap: break-word; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal;"></div><h3 style="font-size: 18.288px; margin: 18.288px 0px 13.716px; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255);"><span style="font-size: 18.288px; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; color: rgb(64, 64, 64); font-family: quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Noto Sans&quot;, Ubuntu, Cantarell, &quot;Helvetica Neue&quot;, Oxygen, &quot;Open Sans&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: bold; line-height: 1.5;">1. 文件头信息冗余（存储空间浪费）</span></h3><ul style="margin: 13.716px 0px; padding-left: 27.432px; font-size: 16.002px; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255);"><li><div style="margin-top: 0px; margin-right: 0px; margin-left: 0px; font-size: 16.002px; margin-bottom: 0px !important;"><span style="font-size: 16.002px; color: rgb(64, 64, 64); font-family: quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Noto Sans&quot;, Ubuntu, Cantarell, &quot;Helvetica Neue&quot;, Oxygen, &quot;Open Sans&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; line-height: 28.575px; font-weight: bold;">问题本质</span><span style="font-size: 16.002px; color: rgb(64, 64, 64); font-family: quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Noto Sans&quot;, Ubuntu, Cantarell, &quot;Helvetica Neue&quot;, Oxygen, &quot;Open Sans&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; line-height: 28.575px;">：每个AB包都包含</span><span style="font-size: 16.002px; color: rgb(64, 64, 64); font-family: quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Noto Sans&quot;, Ubuntu, Cantarell, &quot;Helvetica Neue&quot;, Oxygen, &quot;Open Sans&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; line-height: 28.575px; font-weight: bold;">独立的文件头信息</span><span style="font-size: 16.002px; color: rgb(64, 64, 64); font-family: quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Noto Sans&quot;, Ubuntu, Cantarell, &quot;Helvetica Neue&quot;, Oxygen, &quot;Open Sans&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; line-height: 28.575px;">（描述包内资源结构、依赖关系等元数据）。</span></div></li><li style="margin-top: 4px;"><div><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px !important; margin-left: 0px; font-size: 16.002px; line-height: 28.575px;"></p><div><span style="color: rgb(64, 64, 64); font-family: quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Noto Sans&quot;, Ubuntu, Cantarell, &quot;Helvetica Neue&quot;, Oxygen, &quot;Open Sans&quot;, sans-serif; font-size: 16.002px; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: bold;">过度拆分后果</span><span style="color: rgb(64, 64, 64); font-family: quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Noto Sans&quot;, Ubuntu, Cantarell, &quot;Helvetica Neue&quot;, Oxygen, &quot;Open Sans&quot;, sans-serif; font-size: 16.002px; font-variant-caps: normal; font-variant-ligatures: normal;">：</span></div><div><span style="color: rgb(64, 64, 64); font-family: quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Noto Sans&quot;, Ubuntu, Cantarell, &quot;Helvetica Neue&quot;, Oxygen, &quot;Open Sans&quot;, sans-serif; font-size: 16.002px; font-variant-caps: normal; font-variant-ligatures: normal;">→ 资源虽无重复，但</span><span style="color: rgb(64, 64, 64); font-family: quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Noto Sans&quot;, Ubuntu, Cantarell, &quot;Helvetica Neue&quot;, Oxygen, &quot;Open Sans&quot;, sans-serif; font-size: 16.002px; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: bold;">大量小AB包的文件头信息总和</span><span style="color: rgb(64, 64, 64); font-family: quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Noto Sans&quot;, Ubuntu, Cantarell, &quot;Helvetica Neue&quot;, Oxygen, &quot;Open Sans&quot;, sans-serif; font-size: 16.002px; font-variant-caps: normal; font-variant-ligatures: normal;">会显著增加总容量。</span></div><div style="margin-top: 1em; margin-bottom: 1em;"><span style="color: rgb(64, 64, 64); font-family: quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Noto Sans&quot;, Ubuntu, Cantarell, &quot;Helvetica Neue&quot;, Oxygen, &quot;Open Sans&quot;, sans-serif; font-size: 16.002px; font-variant-caps: normal; font-variant-ligatures: normal;-en-paragraph:true;">→</span><span style="color: rgb(64, 64, 64); font-family: quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Noto Sans&quot;, Ubuntu, Cantarell, &quot;Helvetica Neue&quot;, Oxygen, &quot;Open Sans&quot;, sans-serif; font-size: 16.002px; font-variant-caps: normal; font-variant-ligatures: normal;-en-paragraph:true;"> </span><span style="color: rgb(64, 64, 64); font-family: quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Noto Sans&quot;, Ubuntu, Cantarell, &quot;Helvetica Neue&quot;, Oxygen, &quot;Open Sans&quot;, sans-serif; font-size: 16.002px; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: bold;-en-paragraph:true;">典型场景</span><span style="color: rgb(64, 64, 64); font-family: quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Noto Sans&quot;, Ubuntu, Cantarell, &quot;Helvetica Neue&quot;, Oxygen, &quot;Open Sans&quot;, sans-serif; font-size: 16.002px; font-variant-caps: normal; font-variant-ligatures: normal;-en-paragraph:true;">：1000个资源拆成1000个AB包，文件头可能比资源本身占用更多空间。</span></div></div></li></ul><hr style="height: 1px; margin: 32px 0px; background: none 0% 0% / auto repeat scroll padding-box border-box rgb(229, 229, 229); border: none; display: block; color: rgb(64, 64, 64); font-family: quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Noto Sans&quot;, Ubuntu, Cantarell, &quot;Helvetica Neue&quot;, Oxygen, &quot;Open Sans&quot;, sans-serif; font-size: 16.002px; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal;"/><h3 style="font-size: 18.288px; margin: 18.288px 0px 13.716px; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255);"><span style="font-size: 18.288px; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255); color: rgb(64, 64, 64); font-family: quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Noto Sans&quot;, Ubuntu, Cantarell, &quot;Helvetica Neue&quot;, Oxygen, &quot;Open Sans&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: bold; line-height: 1.5;">2. 网络下载效率降低（传输性能瓶颈）</span></h3><ul style="margin: 13.716px 0px; padding-left: 27.432px; font-size: 16.002px; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255);"><li><div><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px !important; margin-left: 0px; font-size: 16.002px; line-height: 28.575px;"></p><div><span style="color: rgb(64, 64, 64); font-family: quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Noto Sans&quot;, Ubuntu, Cantarell, &quot;Helvetica Neue&quot;, Oxygen, &quot;Open Sans&quot;, sans-serif; font-size: 16.002px; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: bold;">小文件下载缺陷</span><span style="color: rgb(64, 64, 64); font-family: quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Noto Sans&quot;, Ubuntu, Cantarell, &quot;Helvetica Neue&quot;, Oxygen, &quot;Open Sans&quot;, sans-serif; font-size: 16.002px; font-variant-caps: normal; font-variant-ligatures: normal;">：</span></div><div><span style="color: rgb(64, 64, 64); font-family: quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Noto Sans&quot;, Ubuntu, Cantarell, &quot;Helvetica Neue&quot;, Oxygen, &quot;Open Sans&quot;, sans-serif; font-size: 16.002px; font-variant-caps: normal; font-variant-ligatures: normal;">→ 每个AB包需</span><span style="color: rgb(64, 64, 64); font-family: quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Noto Sans&quot;, Ubuntu, Cantarell, &quot;Helvetica Neue&quot;, Oxygen, &quot;Open Sans&quot;, sans-serif; font-size: 16.002px; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: bold;">单独建立网络连接</span><span style="color: rgb(64, 64, 64); font-family: quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Noto Sans&quot;, Ubuntu, Cantarell, &quot;Helvetica Neue&quot;, Oxygen, &quot;Open Sans&quot;, sans-serif; font-size: 16.002px; font-variant-caps: normal; font-variant-ligatures: normal;">（HTTP请求）。</span></div><div style="margin-top: 1em; margin-bottom: 1em;"><span style="color: rgb(64, 64, 64); font-family: quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Noto Sans&quot;, Ubuntu, Cantarell, &quot;Helvetica Neue&quot;, Oxygen, &quot;Open Sans&quot;, sans-serif; font-size: 16.002px; font-variant-caps: normal; font-variant-ligatures: normal;-en-paragraph:true;">→ 连接建立、断开存在固有开销（TCP三次握手、TLS协商等）。</span></div></div></li><li style="margin-top: 4px;"><div><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px !important; margin-left: 0px; font-size: 16.002px; line-height: 28.575px;"></p><div><span style="color: rgb(64, 64, 64); font-family: quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Noto Sans&quot;, Ubuntu, Cantarell, &quot;Helvetica Neue&quot;, Oxygen, &quot;Open Sans&quot;, sans-serif; font-size: 16.002px; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: bold;">带宽利用率不足</span><span style="color: rgb(64, 64, 64); font-family: quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Noto Sans&quot;, Ubuntu, Cantarell, &quot;Helvetica Neue&quot;, Oxygen, &quot;Open Sans&quot;, sans-serif; font-size: 16.002px; font-variant-caps: normal; font-variant-ligatures: normal;">：</span></div><div><span style="color: rgb(64, 64, 64); font-family: quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Noto Sans&quot;, Ubuntu, Cantarell, &quot;Helvetica Neue&quot;, Oxygen, &quot;Open Sans&quot;, sans-serif; font-size: 16.002px; font-variant-caps: normal; font-variant-ligatures: normal;">→ 大量几KB~几十KB的小文件无法占满用户带宽（尤其高延迟网络）。</span></div><div style="margin-top: 1em; margin-bottom: 1em;"><span style="color: rgb(64, 64, 64); font-family: quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Noto Sans&quot;, Ubuntu, Cantarell, &quot;Helvetica Neue&quot;, Oxygen, &quot;Open Sans&quot;, sans-serif; font-size: 16.002px; font-variant-caps: normal; font-variant-ligatures: normal;-en-paragraph:true;">→</span><span style="color: rgb(64, 64, 64); font-family: quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Noto Sans&quot;, Ubuntu, Cantarell, &quot;Helvetica Neue&quot;, Oxygen, &quot;Open Sans&quot;, sans-serif; font-size: 16.002px; font-variant-caps: normal; font-variant-ligatures: normal;-en-paragraph:true;"> </span><span style="color: rgb(64, 64, 64); font-family: quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Noto Sans&quot;, Ubuntu, Cantarell, &quot;Helvetica Neue&quot;, Oxygen, &quot;Open Sans&quot;, sans-serif; font-size: 16.002px; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: bold;-en-paragraph:true;">对比</span><span style="color: rgb(64, 64, 64); font-family: quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Noto Sans&quot;, Ubuntu, Cantarell, &quot;Helvetica Neue&quot;, Oxygen, &quot;Open Sans&quot;, sans-serif; font-size: 16.002px; font-variant-caps: normal; font-variant-ligatures: normal;-en-paragraph:true;">：下载1个100MB文件 vs 1000个0.1MB文件，前者通常快3-5倍（省去999次连接开销）。</span></div></div></li></ul><hr style="height: 1px; margin: 32px 0px; background: none 0% 0% / auto repeat scroll padding-box border-box rgb(229, 229, 229); border: none; display: block; color: rgb(64, 64, 64); font-family: quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Noto Sans&quot;, Ubuntu, Cantarell, &quot;Helvetica Neue&quot;, Oxygen, &quot;Open Sans&quot;, sans-serif; font-size: 16.002px; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal;"/><h3 style="font-size: 18.288px; margin: 18.288px 0px 13.716px; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255);"><span style="font-size: 18.288px; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255); color: rgb(64, 64, 64); font-family: quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Noto Sans&quot;, Ubuntu, Cantarell, &quot;Helvetica Neue&quot;, Oxygen, &quot;Open Sans&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: bold; line-height: 1.5;">3. 加载性能下降（运行时开销）</span></h3><ul style="margin: 13.716px 0px; padding-left: 27.432px; font-size: 16.002px; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255);"><li><div><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px !important; margin-left: 0px; font-size: 16.002px; line-height: 28.575px;"></p><div><span style="color: rgb(64, 64, 64); font-family: quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Noto Sans&quot;, Ubuntu, Cantarell, &quot;Helvetica Neue&quot;, Oxygen, &quot;Open Sans&quot;, sans-serif; font-size: 16.002px; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: bold;">依赖加载延迟</span><span style="color: rgb(64, 64, 64); font-family: quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Noto Sans&quot;, Ubuntu, Cantarell, &quot;Helvetica Neue&quot;, Oxygen, &quot;Open Sans&quot;, sans-serif; font-size: 16.002px; font-variant-caps: normal; font-variant-ligatures: normal;">：</span></div><div><span style="color: rgb(64, 64, 64); font-family: quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Noto Sans&quot;, Ubuntu, Cantarell, &quot;Helvetica Neue&quot;, Oxygen, &quot;Open Sans&quot;, sans-serif; font-size: 16.002px; font-variant-caps: normal; font-variant-ligatures: normal;">→ 加载目标AB包前需</span><span style="color: rgb(64, 64, 64); font-family: quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Noto Sans&quot;, Ubuntu, Cantarell, &quot;Helvetica Neue&quot;, Oxygen, &quot;Open Sans&quot;, sans-serif; font-size: 16.002px; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: bold;">递归加载所有依赖包</span><span style="color: rgb(64, 64, 64); font-family: quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Noto Sans&quot;, Ubuntu, Cantarell, &quot;Helvetica Neue&quot;, Oxygen, &quot;Open Sans&quot;, sans-serif; font-size: 16.002px; font-variant-caps: normal; font-variant-ligatures: normal;">（通过Manifest查询依赖链）。</span></div><div style="margin-top: 1em; margin-bottom: 1em;"><span style="color: rgb(64, 64, 64); font-family: quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Noto Sans&quot;, Ubuntu, Cantarell, &quot;Helvetica Neue&quot;, Oxygen, &quot;Open Sans&quot;, sans-serif; font-size: 16.002px; font-variant-caps: normal; font-variant-ligatures: normal;-en-paragraph:true;">→ 每个依赖包的加载涉及磁盘I/O、内存分配、序列化等操作。</span></div></div></li><li style="margin-top: 4px;"><div><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px !important; margin-left: 0px; font-size: 16.002px; line-height: 28.575px;"></p><div><span style="color: rgb(64, 64, 64); font-family: quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Noto Sans&quot;, Ubuntu, Cantarell, &quot;Helvetica Neue&quot;, Oxygen, &quot;Open Sans&quot;, sans-serif; font-size: 16.002px; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: bold;">真实耗时</span><span style="color: rgb(64, 64, 64); font-family: quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Noto Sans&quot;, Ubuntu, Cantarell, &quot;Helvetica Neue&quot;, Oxygen, &quot;Open Sans&quot;, sans-serif; font-size: 16.002px; font-variant-caps: normal; font-variant-ligatures: normal;">：</span></div><div><span style="color: rgb(64, 64, 64); font-family: quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Noto Sans&quot;, Ubuntu, Cantarell, &quot;Helvetica Neue&quot;, Oxygen, &quot;Open Sans&quot;, sans-serif; font-size: 16.002px; font-variant-caps: normal; font-variant-ligatures: normal;">→ 单个AB包加载耗时约1~10ms（取决于大小），但</span><span style="color: rgb(64, 64, 64); font-family: quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Noto Sans&quot;, Ubuntu, Cantarell, &quot;Helvetica Neue&quot;, Oxygen, &quot;Open Sans&quot;, sans-serif; font-size: 16.002px; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: bold;">成千上万次累积</span><span style="color: rgb(64, 64, 64); font-family: quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Noto Sans&quot;, Ubuntu, Cantarell, &quot;Helvetica Neue&quot;, Oxygen, &quot;Open Sans&quot;, sans-serif; font-size: 16.002px; font-variant-caps: normal; font-variant-ligatures: normal;">会导致卡顿。</span></div><div style="margin-top: 1em; margin-bottom: 1em;"><span style="color: rgb(64, 64, 64); font-family: quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Noto Sans&quot;, Ubuntu, Cantarell, &quot;Helvetica Neue&quot;, Oxygen, &quot;Open Sans&quot;, sans-serif; font-size: 16.002px; font-variant-caps: normal; font-variant-ligatures: normal;-en-paragraph:true;">→ 虽“感觉不明显”，但在低端设备或复杂依赖场景下会成为瓶颈。</span></div></div></li></ul><hr style="height: 1px; margin: 32px 0px; background: none 0% 0% / auto repeat scroll padding-box border-box rgb(229, 229, 229); border: none; display: block; color: rgb(64, 64, 64); font-family: quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Noto Sans&quot;, Ubuntu, Cantarell, &quot;Helvetica Neue&quot;, Oxygen, &quot;Open Sans&quot;, sans-serif; font-size: 16.002px; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal;"/><h3 style="font-size: 18.288px; margin: 18.288px 0px 13.716px; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255);"><span style="font-size: 18.288px; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255); color: rgb(64, 64, 64); font-family: quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Noto Sans&quot;, Ubuntu, Cantarell, &quot;Helvetica Neue&quot;, Oxygen, &quot;Open Sans&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: bold; line-height: 1.5;">4. 内存占用激增（关键问题）</span></h3><ul style="margin: 13.716px 0px; padding-left: 27.432px; font-size: 16.002px; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255);"><li><div><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px !important; margin-left: 0px; font-size: 16.002px; line-height: 28.575px;"></p><div><span style="color: rgb(64, 64, 64); font-family: quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Noto Sans&quot;, Ubuntu, Cantarell, &quot;Helvetica Neue&quot;, Oxygen, &quot;Open Sans&quot;, sans-serif; font-size: 16.002px; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: bold;">元数据膨胀</span><span style="color: rgb(64, 64, 64); font-family: quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Noto Sans&quot;, Ubuntu, Cantarell, &quot;Helvetica Neue&quot;, Oxygen, &quot;Open Sans&quot;, sans-serif; font-size: 16.002px; font-variant-caps: normal; font-variant-ligatures: normal;">：</span></div><div style="margin-top: 1em; margin-bottom: 1em;"><span style="color: rgb(64, 64, 64); font-family: quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Noto Sans&quot;, Ubuntu, Cantarell, &quot;Helvetica Neue&quot;, Oxygen, &quot;Open Sans&quot;, sans-serif; font-size: 16.002px; font-variant-caps: normal; font-variant-ligatures: normal;-en-paragraph:true;">→ 每个加载的AB包在内存中维护</span><span style="color: rgb(64, 64, 64); font-family: quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Noto Sans&quot;, Ubuntu, Cantarell, &quot;Helvetica Neue&quot;, Oxygen, &quot;Open Sans&quot;, sans-serif; font-size: 16.002px; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: bold;-en-paragraph:true;">独立的数据结构</span><span style="color: rgb(64, 64, 64); font-family: quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Noto Sans&quot;, Ubuntu, Cantarell, &quot;Helvetica Neue&quot;, Oxygen, &quot;Open Sans&quot;, sans-serif; font-size: 16.002px; font-variant-caps: normal; font-variant-ligatures: normal;-en-paragraph:true;">（包括资源索引、依赖映射等）。</span></div></div></li><li style="margin-top: 4px;"><div style="margin: 0px 0px 4px; font-size: 16.002px;"><span style="font-size: 16.002px; color: rgb(64, 64, 64); font-family: quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Noto Sans&quot;, Ubuntu, Cantarell, &quot;Helvetica Neue&quot;, Oxygen, &quot;Open Sans&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; line-height: 28.575px; font-weight: bold;">实例对比</span><span style="font-size: 16.002px; color: rgb(64, 64, 64); font-family: quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Noto Sans&quot;, Ubuntu, Cantarell, &quot;Helvetica Neue&quot;, Oxygen, &quot;Open Sans&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; line-height: 28.575px;">：</span></div><div style="--ds-md-code-block-border-color: #e5e5e5; --ds-md-code-block-banner-wrap-background-color: white; --ds-md-code-banner-background-color: #f5f5f5; background: rgb(250, 250, 250); --ds-md-code-block-border-radius: 12px; --ds-md-code-block-font-size: calc(1.143*11px); border-radius: 12px; font-size: 12.573px; margin-bottom: 0px;"><div style="background-color: rgb(255, 255, 255); z-index: 6; position: sticky; top: 0px;"><div style="background: none 0% 0% / auto repeat scroll padding-box border-box rgb(245, 245, 245); padding: 0px; font-size: 12.573px; justify-content: space-between; display: flex; border-top-left-radius: 12px; border-top-right-radius: 12px;"><div style="justify-content: space-between; align-items: center; width: 704.578px; padding: 6px 14px 6px 6px; display: flex;"><div style="flex-shrink: 0;"><span style="font-size: 12px; color: rgb(82, 82, 82); font-family: quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Noto Sans&quot;, Ubuntu, Cantarell, &quot;Helvetica Neue&quot;, Oxygen, &quot;Open Sans&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; line-height: 18px;">markdown</span></div><div style="flex-shrink: 0;"><div style="height: 28px; align-items: center; display: flex;"><div style="--ds-rgb-error-hover: 218 54 54; --ds-button-color: transparent; --button-ring-color: rgb(59 130 246); height: 28px; font-size: 13px; border-radius: 10px; padding: 0px 4px; user-select: none; cursor: pointer; white-space: nowrap; box-sizing: border-box; transition: opacity 0.2s cubic-bezier(0.4, 0, 0.2, 1), background-color 0.2s cubic-bezier(0.4, 0, 0.2, 1); outline: none; align-items: center; display: inline-flex; position: relative; background-color: rgba(0, 0, 0, 0); --button-height: 34px; --button-font-size: 14px; --button-line-height: 25px; --button-border-radius: 10px; --button-padding: 0 14px; --button-icon-size: 18px; --button-icon-margin: 0 8px 0 0; margin-right: 8px; --button-text-color: rgb(82 82 82);"><span style="--ds-rgb-error-hover: 218 54 54; --ds-button-color: transparent; --button-ring-color: rgb(59 130 246); height: 28px; font-size: 13px; border-radius: 10px; user-select: none; cursor: pointer; white-space: nowrap; box-sizing: border-box; outline: none; display: inline-flex; position: relative; background-color: rgba(0, 0, 0, 0); --button-height: 34px; --button-font-size: 14px; --button-line-height: 25px; --button-border-radius: 10px; --button-padding: 0 14px; --button-icon-size: 18px; --button-icon-margin: 0 8px 0 0; --button-text-color: rgb(82 82 82); color: rgb(82, 82, 82); font-family: quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Noto Sans&quot;, Ubuntu, Cantarell, &quot;Helvetica Neue&quot;, Oxygen, &quot;Open Sans&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; line-height: 25px; font-variant-numeric: tabular-nums;">复制</span></div><div style="--ds-rgb-error-hover: 218 54 54; --ds-button-color: transparent; --button-ring-color: rgb(59 130 246); height: 28px; font-size: 13px; border-radius: 10px; padding: 0px 4px; user-select: none; cursor: pointer; white-space: nowrap; box-sizing: border-box; transition: opacity 0.2s cubic-bezier(0.4, 0, 0.2, 1), background-color 0.2s cubic-bezier(0.4, 0, 0.2, 1); outline: none; align-items: center; display: inline-flex; position: relative; background-color: rgba(0, 0, 0, 0); --button-height: 30px; --button-font-size: 13px; --button-line-height: 21px; --button-border-radius: 10px; --button-padding: 0 14px; --button-icon-size: 18px; --button-icon-margin: 0 8px 0 0; --button-text-color: rgb(82 82 82);"><span style="--ds-rgb-error-hover: 218 54 54; --ds-button-color: transparent; --button-ring-color: rgb(59 130 246); height: 28px; font-size: 13px; border-radius: 10px; user-select: none; cursor: pointer; white-space: nowrap; box-sizing: border-box; outline: none; display: inline-flex; position: relative; background-color: rgba(0, 0, 0, 0); --button-height: 30px; --button-font-size: 13px; --button-line-height: 21px; --button-border-radius: 10px; --button-padding: 0 14px; --button-icon-size: 18px; --button-icon-margin: 0 8px 0 0; --button-text-color: rgb(82 82 82); color: rgb(82, 82, 82); font-family: quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Noto Sans&quot;, Ubuntu, Cantarell, &quot;Helvetica Neue&quot;, Oxygen, &quot;Open Sans&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; line-height: 21px; font-variant-numeric: tabular-nums;">下载</span></div></div></div></div></div></div><div style="overflow: auto; padding: 9.144px 13.716px; white-space: pre-wrap; word-break: break-all; margin: 0px !important;"><div><span style="color: rgb(56, 58, 66); font-family: Menlo, &quot;Roboto Mono&quot;, &quot;Courier New&quot;, Courier, monospace, Inter, sans-serif; font-size: 12.573px; font-variant-caps: normal; font-variant-ligatures: normal; line-height: 20.1168px;">-</span> <span style="color: rgb(73, 73, 73); font-family: Menlo, &quot;Roboto Mono&quot;, &quot;Courier New&quot;, Courier, monospace, Inter, sans-serif; font-size: 12.573px; font-variant-caps: normal; font-variant-ligatures: normal; line-height: 20.1168px;">合并包：1个AB包加载后占用1份元数据内存（如10KB）</span></div><div><span style="color: rgb(56, 58, 66); font-family: Menlo, &quot;Roboto Mono&quot;, &quot;Courier New&quot;, Courier, monospace, Inter, sans-serif; font-size: 12.573px; font-variant-caps: normal; font-variant-ligatures: normal; line-height: 20.1168px;">-</span> <span style="color: rgb(73, 73, 73); font-family: Menlo, &quot;Roboto Mono&quot;, &quot;Courier New&quot;, Courier, monospace, Inter, sans-serif; font-size: 12.573px; font-variant-caps: normal; font-variant-ligatures: normal; line-height: 20.1168px;">拆分包：1000个AB包占用1000份元数据内存（如10MB）</span></div></div></div></li><li style="margin-top: 4px;"><div><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px !important; margin-left: 0px; font-size: 16.002px; line-height: 28.575px;"></p><div><span style="color: rgb(64, 64, 64); font-family: quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Noto Sans&quot;, Ubuntu, Cantarell, &quot;Helvetica Neue&quot;, Oxygen, &quot;Open Sans&quot;, sans-serif; font-size: 16.002px; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: bold;">隐性消耗</span><span style="color: rgb(64, 64, 64); font-family: quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Noto Sans&quot;, Ubuntu, Cantarell, &quot;Helvetica Neue&quot;, Oxygen, &quot;Open Sans&quot;, sans-serif; font-size: 16.002px; font-variant-caps: normal; font-variant-ligatures: normal;">：</span></div><div><span style="color: rgb(64, 64, 64); font-family: quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Noto Sans&quot;, Ubuntu, Cantarell, &quot;Helvetica Neue&quot;, Oxygen, &quot;Open Sans&quot;, sans-serif; font-size: 16.002px; font-variant-caps: normal; font-variant-ligatures: normal;">→ 大量小AB包导致</span><span style="color: rgb(64, 64, 64); font-family: quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Noto Sans&quot;, Ubuntu, Cantarell, &quot;Helvetica Neue&quot;, Oxygen, &quot;Open Sans&quot;, sans-serif; font-size: 16.002px; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: bold;">内存碎片化</span><span style="color: rgb(64, 64, 64); font-family: quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Noto Sans&quot;, Ubuntu, Cantarell, &quot;Helvetica Neue&quot;, Oxygen, &quot;Open Sans&quot;, sans-serif; font-size: 16.002px; font-variant-caps: normal; font-variant-ligatures: normal;">，降低内存利用率。</span></div><div style="margin-top: 1em; margin-bottom: 1em;"><span style="color: rgb(64, 64, 64); font-family: quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Noto Sans&quot;, Ubuntu, Cantarell, &quot;Helvetica Neue&quot;, Oxygen, &quot;Open Sans&quot;, sans-serif; font-size: 16.002px; font-variant-caps: normal; font-variant-ligatures: normal;-en-paragraph:true;">→ 频繁加载/卸载加剧GC压力，可能引发帧率波动。</span></div></div></li></ul><hr/><div><br/></div><ul><li><div>校验Ab</div></li><ul><li><div><span style="font-weight: bold;">manifest文件带的CRC值检查ab完整性</span></div></li></ul><li><div>加载AB包</div></li><ul><li><div>AssetBundle.LoadFromMemory（可选择异步模式）一般用于读取加密的ab</div></li><ul><li><div>byte[]  =&gt; File.ReadBytes</div></li><li><div><span style="font-size: 16.002px; color: unset; font-family: unset; font-weight: bold; line-height: 28.575px;">功能：</span><span style="font-size: 16.002px; color: unset; font-family: unset; line-height: 28.575px;"> </span><span style="font-size: 16.002px; color: unset; font-family: unset; line-height: 28.575px;">从内存中的</span><span style="font-size: 16.002px; color: unset; font-family: unset; line-height: 28.575px;"> </span><span style="font-size: 0.875em; background-color: rgb(236, 236, 236); border-radius: 4px; color: unset; font-family: Menlo, &quot;Roboto Mono&quot;, &quot;Courier New&quot;, Courier, monospace, Inter, sans-serif; font-weight: bold; line-height: 28.575px;">byte[]</span><span style="font-size: 16.002px; color: unset; font-family: unset; font-weight: bold; line-height: 28.575px;"> </span><span style="font-size: 16.002px; color: unset; font-family: unset; font-weight: bold; line-height: 28.575px;">数组</span><span style="font-size: 16.002px; color: unset; font-family: unset; line-height: 28.575px;">加载 AssetBundle。</span></div></li><li style="margin-top: 4px;"><div style="margin: 0px 0px 4px; font-size: 16.002px;"><span style="font-size: 16.002px; font-weight: bold; line-height: 28.575px;">特点：</span></div></li><ul style="margin: 4px 0px 0px; padding-left: 27.432px;"><li><div style="margin-top: 0px; margin-right: 0px; margin-left: 0px; font-size: 16.002px; margin-bottom: 0px !important;"><span style="font-size: 16.002px; font-weight: bold; line-height: 28.575px;">内存消耗大：</span><span style="font-size: 16.002px; line-height: 28.575px;"> </span><span style="font-size: 16.002px; line-height: 28.575px;">需要先将整个 AssetBundle 文件读取到内存中形成</span><span style="font-size: 16.002px; line-height: 28.575px;"> </span><span style="font-size: 0.875em; background-color: rgb(236, 236, 236); border-radius: 4px; font-family: Menlo, &quot;Roboto Mono&quot;, &quot;Courier New&quot;, Courier, monospace, Inter, sans-serif; font-weight: bold; line-height: 28.575px;">byte[]</span><span style="font-size: 16.002px; line-height: 28.575px;">，然后 Unity 会</span><span style="font-size: 16.002px; font-weight: bold; line-height: 28.575px;">复制</span><span style="font-size: 16.002px; line-height: 28.575px;">一份数据进行加载。这意味着原始数组和 Unity 内部各存一份完整数据，</span><span style="font-size: 16.002px; font-weight: bold; line-height: 28.575px;">内存峰值翻倍</span><span style="font-size: 16.002px; line-height: 28.575px;">！性能开销较大。</span></div></li><li style="margin-top: 4px;"><div style="margin-top: 0px; margin-right: 0px; margin-left: 0px; font-size: 16.002px; margin-bottom: 0px !important;"><span style="font-size: 16.002px; font-weight: bold; line-height: 28.575px;">使用场景有限：</span><span style="font-size: 16.002px; line-height: 28.575px;"> </span><span style="font-size: 16.002px; line-height: 28.575px;">通常用于处理</span><span style="font-size: 16.002px; font-weight: bold; line-height: 28.575px;">加密</span><span style="font-size: 16.002px; line-height: 28.575px;">的 AssetBundle（先解密到内存字节数组）或从网络下载后已缓存在内存中的字节流（但通常有更好的方式处理网络下载）。</span></div></li></ul><li><div style="margin-top: 0px; margin-right: 0px; margin-left: 0px; font-size: 16.002px; margin-bottom: 0px !important;"><span style="font-size: 16.002px; font-weight: bold; line-height: 28.575px;">慎用：</span><span style="font-size: 16.002px; line-height: 28.575px;"> </span><span style="font-size: 16.002px; font-weight: bold; line-height: 28.575px;">一般不建议使用</span><span style="font-size: 16.002px; line-height: 28.575px;">，除非有非常特定的需求（如强加密）。</span></div></li></ul><li><div>AssetBundle.LoadFromFile（可选择异步模式）  是用于从本地存储加载未压缩或使用LZ4压缩的AssetBundle的高效API。LZMA格式的将会先被解压，然后再压缩成LZ4格式，放到非托管堆。</div></li><li><div>AssetBundle.LoadFromStream（可选择异步模式）通过文件流一点点读取，它会分次从文件里读取32KB放在非托管内存中</div></li><ul><li><div>FileStream</div></li></ul><li><div>LoadFromFile方法是最优的加载方式，LoadFromMemory则用于需要加密的AssetBundle包<img src="Evernote_files/Image [32].png" type="image/png" data-filename="Image.png"/></div></li></ul><li><div>加载包内资源</div></li><li><div>分包策略  <a href="https://www.jianshu.com/p/80f432eda30d">AssetBundle实战：资源冗余，分包策略，加载和卸载 - 简书 (jianshu.com)</a></div></li><li><div><a href="http://t.csdnimg.cn/bKV3Q">http://t.csdnimg.cn/bKV3Q</a> </div></li></ul><div><br/></div><hr/><div style="margin: 0px 0px 4px; font-size: 16.002px; letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255);"><span style="font-size: 16.002px; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255); color: rgb(64, 64, 64); font-family: quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Noto Sans&quot;, Ubuntu, Cantarell, &quot;Helvetica Neue&quot;, Oxygen, &quot;Open Sans&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: bold; line-height: 28.575px;">卸载 AssetBundle (</span><span style="font-size: 0.875em; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(236, 236, 236); border-radius: 4px; color: rgb(64, 64, 64); font-family: Menlo, &quot;Roboto Mono&quot;, &quot;Courier New&quot;, Courier, monospace, Inter, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: bold; line-height: 28.575px;">AssetBundle.Unload</span><span style="font-size: 16.002px; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255); color: rgb(64, 64, 64); font-family: quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Noto Sans&quot;, Ubuntu, Cantarell, &quot;Helvetica Neue&quot;, Oxygen, &quot;Open Sans&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: bold; line-height: 28.575px;">)：</span></div><ul style="margin: 4px 0px 0px; padding-left: 27.432px; font-size: 16.002px; letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255);"><li><div style="margin-top: 0px; margin-right: 0px; margin-left: 0px; font-size: 16.002px; margin-bottom: 0px !important;"><span style="font-size: 0.875em; background-color: rgb(236, 236, 236); border-radius: 4px; color: rgb(64, 64, 64); font-family: Menlo, &quot;Roboto Mono&quot;, &quot;Courier New&quot;, Courier, monospace, Inter, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: bold; line-height: 28.575px;">bundle.Unload(false)</span><span style="font-size: 16.002px; color: rgb(64, 64, 64); font-family: quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Noto Sans&quot;, Ubuntu, Cantarell, &quot;Helvetica Neue&quot;, Oxygen, &quot;Open Sans&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: bold; line-height: 28.575px;">：</span><span style="font-size: 16.002px; color: rgb(64, 64, 64); font-family: quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Noto Sans&quot;, Ubuntu, Cantarell, &quot;Helvetica Neue&quot;, Oxygen, &quot;Open Sans&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; line-height: 28.575px;"> </span><span style="font-size: 16.002px; color: rgb(64, 64, 64); font-family: quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Noto Sans&quot;, Ubuntu, Cantarell, &quot;Helvetica Neue&quot;, Oxygen, &quot;Open Sans&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; line-height: 28.575px;">只卸载 AssetBundle 文件本身的内存镜像（头信息等），</span><span style="font-size: 16.002px; color: rgb(64, 64, 64); font-family: quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Noto Sans&quot;, Ubuntu, Cantarell, &quot;Helvetica Neue&quot;, Oxygen, &quot;Open Sans&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: bold; line-height: 28.575px;">不卸载</span><span style="font-size: 16.002px; color: rgb(64, 64, 64); font-family: quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Noto Sans&quot;, Ubuntu, Cantarell, &quot;Helvetica Neue&quot;, Oxygen, &quot;Open Sans&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; line-height: 28.575px;">已从中加载出来的资源对象（如 Prefab、Texture）。这些资源仍在内存中，可以继续使用。但如果后续尝试从</span><span style="font-size: 16.002px; color: rgb(64, 64, 64); font-family: quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Noto Sans&quot;, Ubuntu, Cantarell, &quot;Helvetica Neue&quot;, Oxygen, &quot;Open Sans&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: bold; line-height: 28.575px;">同一个</span><span style="font-size: 16.002px; color: rgb(64, 64, 64); font-family: quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Noto Sans&quot;, Ubuntu, Cantarell, &quot;Helvetica Neue&quot;, Oxygen, &quot;Open Sans&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; line-height: 28.575px;"> </span><span style="font-size: 16.002px; color: rgb(64, 64, 64); font-family: quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Noto Sans&quot;, Ubuntu, Cantarell, &quot;Helvetica Neue&quot;, Oxygen, &quot;Open Sans&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; line-height: 28.575px;">AssetBundle 再次加载资源会失败（因为包已卸载）。</span></div></li><li style="margin-top: 4px;"><div style="margin-top: 0px; margin-right: 0px; margin-left: 0px; font-size: 16.002px; margin-bottom: 0px !important;"><span style="font-size: 0.875em; background-color: rgb(236, 236, 236); border-radius: 4px; color: rgb(64, 64, 64); font-family: Menlo, &quot;Roboto Mono&quot;, &quot;Courier New&quot;, Courier, monospace, Inter, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: bold; line-height: 28.575px;">bundle.Unload(true)</span><span style="font-size: 16.002px; color: rgb(64, 64, 64); font-family: quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Noto Sans&quot;, Ubuntu, Cantarell, &quot;Helvetica Neue&quot;, Oxygen, &quot;Open Sans&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: bold; line-height: 28.575px;">：</span><span style="font-size: 16.002px; color: rgb(64, 64, 64); font-family: quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Noto Sans&quot;, Ubuntu, Cantarell, &quot;Helvetica Neue&quot;, Oxygen, &quot;Open Sans&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; line-height: 28.575px;"> </span><span style="font-size: 16.002px; color: rgb(64, 64, 64); font-family: quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Noto Sans&quot;, Ubuntu, Cantarell, &quot;Helvetica Neue&quot;, Oxygen, &quot;Open Sans&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: bold; line-height: 28.575px;">卸载 AssetBundle 文件本身的内存镜像，并且强制卸载所有从该包中加载出来的资源对象。</span><span style="font-size: 16.002px; color: rgb(64, 64, 64); font-family: quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Noto Sans&quot;, Ubuntu, Cantarell, &quot;Helvetica Neue&quot;, Oxygen, &quot;Open Sans&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; line-height: 28.575px;"> </span><span style="font-size: 16.002px; color: rgb(64, 64, 64); font-family: quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Noto Sans&quot;, Ubuntu, Cantarell, &quot;Helvetica Neue&quot;, Oxygen, &quot;Open Sans&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; line-height: 28.575px;">如果场景中还有对象引用这些资源，引用会变成 Missing（粉色网格/材质丢失状态）！</span><span style="font-size: 16.002px; color: rgb(64, 64, 64); font-family: quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Noto Sans&quot;, Ubuntu, Cantarell, &quot;Helvetica Neue&quot;, Oxygen, &quot;Open Sans&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: bold; line-height: 28.575px;">极其危险，使用需极度谨慎！</span><span style="font-size: 16.002px; color: rgb(64, 64, 64); font-family: quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Noto Sans&quot;, Ubuntu, Cantarell, &quot;Helvetica Neue&quot;, Oxygen, &quot;Open Sans&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; line-height: 28.575px;"> </span><span style="font-size: 16.002px; color: rgb(64, 64, 64); font-family: quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Noto Sans&quot;, Ubuntu, Cantarell, &quot;Helvetica Neue&quot;, Oxygen, &quot;Open Sans&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; line-height: 28.575px;">通常只在确定该包所有资源都</span><span style="font-size: 16.002px; color: rgb(64, 64, 64); font-family: quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Noto Sans&quot;, Ubuntu, Cantarell, &quot;Helvetica Neue&quot;, Oxygen, &quot;Open Sans&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: bold; line-height: 28.575px;">不再使用</span><span style="font-size: 16.002px; color: rgb(64, 64, 64); font-family: quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Noto Sans&quot;, Ubuntu, Cantarell, &quot;Helvetica Neue&quot;, Oxygen, &quot;Open Sans&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; line-height: 28.575px;">（且场景中没有实例引用它们）时调用。</span></div></li><li style="margin-top: 4px;"><div style="margin-top: 0px; margin-right: 0px; margin-left: 0px; font-size: 16.002px; margin-bottom: 0px !important;"><span style="font-size: 16.002px; color: rgb(64, 64, 64); font-family: quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Noto Sans&quot;, Ubuntu, Cantarell, &quot;Helvetica Neue&quot;, Oxygen, &quot;Open Sans&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: bold; line-height: 28.575px;">最佳实践：</span><span style="font-size: 16.002px; color: rgb(64, 64, 64); font-family: quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Noto Sans&quot;, Ubuntu, Cantarell, &quot;Helvetica Neue&quot;, Oxygen, &quot;Open Sans&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; line-height: 28.575px;"> </span><span style="font-size: 16.002px; color: rgb(64, 64, 64); font-family: quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Noto Sans&quot;, Ubuntu, Cantarell, &quot;Helvetica Neue&quot;, Oxygen, &quot;Open Sans&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; line-height: 28.575px;">一般采用</span><span style="font-size: 16.002px; color: rgb(64, 64, 64); font-family: quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Noto Sans&quot;, Ubuntu, Cantarell, &quot;Helvetica Neue&quot;, Oxygen, &quot;Open Sans&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; line-height: 28.575px;"> </span><span style="font-size: 0.875em; background-color: rgb(236, 236, 236); border-radius: 4px; color: rgb(64, 64, 64); font-family: Menlo, &quot;Roboto Mono&quot;, &quot;Courier New&quot;, Courier, monospace, Inter, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: bold; line-height: 28.575px;">Unload(false)</span><span style="font-size: 16.002px; color: rgb(64, 64, 64); font-family: quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Noto Sans&quot;, Ubuntu, Cantarell, &quot;Helvetica Neue&quot;, Oxygen, &quot;Open Sans&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; line-height: 28.575px;">。资源对象的生命周期管理通常结合引用计数、场景卸载或专门的资源池管理策略</span></div></li></ul></div><div><br/></div><hr/><div style="margin: 1.4em 0px; font-size: medium; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255);"><span style="font-size: medium; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255); color: rgb(25, 27, 31); font-family: -apple-system, BlinkMacSystemFont, &quot;Helvetica Neue&quot;, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Source Han Sans SC&quot;, &quot;Noto Sans CJK SC&quot;, &quot;WenQuanYi Micro Hei&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: bold;">加载AssetBundle 资源，运行游戏时出现材质丢失问题解决方法：</span></div><div style="margin: 1.4em 0px; font-size: medium; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255);"><span style="font-size: medium; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255); color: rgb(25, 27, 31); font-family: -apple-system, BlinkMacSystemFont, &quot;Helvetica Neue&quot;, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Source Han Sans SC&quot;, &quot;Noto Sans CJK SC&quot;, &quot;WenQuanYi Micro Hei&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">1，我们在打包</span><span style="font-size: medium; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255); color: rgb(25, 27, 31); font-family: -apple-system, BlinkMacSystemFont, &quot;Helvetica Neue&quot;, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Source Han Sans SC&quot;, &quot;Noto Sans CJK SC&quot;, &quot;WenQuanYi Micro Hei&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: bold;">AB包</span><span style="font-size: medium; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255); color: rgb(25, 27, 31); font-family: -apple-system, BlinkMacSystemFont, &quot;Helvetica Neue&quot;, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Source Han Sans SC&quot;, &quot;Noto Sans CJK SC&quot;, &quot;WenQuanYi Micro Hei&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">的时候，Unity默认是不连Shader一同打包进去的，所以当我们在</span></div><div style="margin: 1.4em 0px; font-size: medium; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255);"><span style="font-size: medium; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255); color: rgb(25, 27, 31); font-family: -apple-system, BlinkMacSystemFont, &quot;Helvetica Neue&quot;, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Source Han Sans SC&quot;, &quot;Noto Sans CJK SC&quot;, &quot;WenQuanYi Micro Hei&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">发布运行的时候就会出现材质丢失的问题，所以这个时候就需要我们自行添加了，添加步骤如</span></div><div style="margin: 1.4em 0px; font-size: medium; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255);"><span style="font-size: medium; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255); color: rgb(25, 27, 31); font-family: -apple-system, BlinkMacSystemFont, &quot;Helvetica Neue&quot;, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Source Han Sans SC&quot;, &quot;Noto Sans CJK SC&quot;, &quot;WenQuanYi Micro Hei&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">下：点击</span><span style="font-size: medium; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255); color: rgb(25, 27, 31); font-family: -apple-system, BlinkMacSystemFont, &quot;Helvetica Neue&quot;, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Source Han Sans SC&quot;, &quot;Noto Sans CJK SC&quot;, &quot;WenQuanYi Micro Hei&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: bold;">Edit&gt;Project Settings&gt;Graphics</span><span style="font-size: medium; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255); color: rgb(25, 27, 31); font-family: -apple-system, BlinkMacSystemFont, &quot;Helvetica Neue&quot;, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Source Han Sans SC&quot;, &quot;Noto Sans CJK SC&quot;, &quot;WenQuanYi Micro Hei&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">，然后下拉到</span><span style="font-size: medium; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255); color: rgb(25, 27, 31); font-family: -apple-system, BlinkMacSystemFont, &quot;Helvetica Neue&quot;, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Source Han Sans SC&quot;, &quot;Noto Sans CJK SC&quot;, &quot;WenQuanYi Micro Hei&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: bold;">Always Included Shaders，</span></div><div style="margin: 1.4em 0px; font-size: medium; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255);"><span style="font-size: medium; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255); color: rgb(25, 27, 31); font-family: -apple-system, BlinkMacSystemFont, &quot;Helvetica Neue&quot;, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Source Han Sans SC&quot;, &quot;Noto Sans CJK SC&quot;, &quot;WenQuanYi Micro Hei&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">将Size改大一些，然后在将丢失的那个材质所使用的Shader添加进去，然后再重新打包运</span></div><div style="margin: 1.4em 0px; font-size: medium; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255);"><span style="font-size: medium; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; color: rgb(25, 27, 31); font-family: -apple-system, BlinkMacSystemFont, &quot;Helvetica Neue&quot;, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Source Han Sans SC&quot;, &quot;Noto Sans CJK SC&quot;, &quot;WenQuanYi Micro Hei&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">行就可解决材质丢失的问题。</span></div><div><img src="Evernote_files/Image [1].jpg" type="image/jpeg" data-filename="Image.jpg" style="display: block; margin: 0px auto; max-width: 100%; height: auto; background-color: rgb(255, 255, 255); cursor: zoom-in; width: 654px;" width="1003"/></div><div><br/></div></div><hr/><div><br/></div></div><hr/><div><br/></div></div><div><br/></div></span>
</div>
<hr>
<a name="624"/>

<div>
<span><div><div><div><div><div><div><font style="font-size: 16pt;"><span style="font-size: 16pt; font-weight: bold;">Unity 合批</span></font></div><div>游戏中如何渲染模型 -&gt; 批处理 -&gt;合批</div><div>渲染模型流程:</div><ol><li><div> 应用数据准备阶段,cpu将模型的顶点,网格,法线,shader,贴图等数据加载到显存中</div></li><li><div>设置渲染状态,cpu告诉gpu该模型渲染需要使用的shader,贴图信息  -setPass</div></li><li><div>cpu通知gpu渲染 -drawCall</div></li></ol><div>批处理: 将多个小网格合并成一个大网格的操作,这样可以将小网格同一批次处理只调用一次drawCall</div></div><ul><li><div><span style="font-weight: bold;">相比于让Gpu渲染100次网格, 将100个网格合并成一个大网格渲染一次是更加有效率的</span></div></li><li><div><font style="font-size: 10pt;"><span style="box-sizing: border-box; outline: 0px; --el-button-hover-bg-color: #6d5ffd; --el-button-hover-border-color: #6d5ffd; --el-button-active-bg-color: #6d5ffd; --el-button-active-border-color: #6d5ffd; overflow-wrap: break-word; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal;"><span style="font-size: 10pt; color: rgb(77, 77, 77); font-style: italic; font-variant-caps: normal; font-variant-ligatures: no-common-ligatures; font-weight: bold;">一定要使用相同材质和相同贴图的模型才可以批处理</span></span><span style="letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; font-size: 10pt; color: rgb(77, 77, 77); font-family: -apple-system, &quot;SF UI Text&quot;, Arial, &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, &quot;WenQuanYi Micro Hei&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: no-common-ligatures;">，一个模型使用的材质或贴图与其他模型不同，那么CPU就得单独进行步骤②设置渲染状态，紧接着也就得单独进行步骤③调用Draw Call。</span></font></div></li></ul><div>Unity合批:静态合批,动态合批,UGUI合批</div><div><span style="font-style: italic; font-weight: bold;">是否能合批和物体间的mash没有关系,相同材质的圆柱和方块也能合批</span></div><div><span style="font-size: 12pt; font-weight: bold;">静态合批</span></div><div><img src="Evernote_files/Image [33].png" type="image/png" data-filename="Image.png" width="804"/></div><div>限制: </div><ol><li><div>合批合批! 需要<span style="font-weight: bold;">相同材质</span>物体才能进行</div></li><li><div>单次合批最多能合并64000个顶点</div></li><li><div>物体需要处于激活状态且网格的读写需要开启</div></li><li><div>代码动态创建的物体不能生效;只有游戏运行前场景中勾选static的物体才能进行静态批处理</div></li></ol><div>优点: 减少drawCall(因为把相同材质物体的网格合并了,一次draw就可以渲染出来</div><div>缺点:</div><ol><li><div>被设置为static的物体不能移动等</div></li><li><div>增大内存开销(因为合并成新的网格</div></li></ol><div>应用场景:游戏中不需要交互的物体,游戏场景和背景元素等</div><div><span style="font-size: 12pt; font-weight: bold;">动态合批 </span><span style="font-size: 12pt;"><a href="https://blog.csdn.net/ww1351646544/article/details/139678759" style="font-size: 12pt; font-weight: bold;">https://blog.csdn.net/ww1351646544/article/details/139678759</a></span></div><div><span style="font-size: 12pt;"><span style="font-size: 12pt; font-weight: bold;"><img src="Evernote_files/Image [34].png" type="image/png" data-filename="Image.png"/></span></span></div><div><span style="font-size: 10pt;">和静态合批不同的是,动态合批的物体是可以运动的</span></div><div>限制: </div><ol><li><div>合批合批,需要<span style="font-weight: bold;">相同材质</span>物体才能进行</div></li><li><div>单个物体的顶点数不能超过300个<img src="Evernote_files/Image [35].png" type="image/png" data-filename="Image.png"/></div></li><li><div>物体的shader具有多个pass也会动态合批失败</div></li><li><div>动态合批的物体只会受一个光源影响</div></li></ol><div><span style="font-size: 12pt; font-weight: bold;">UGUI合批 </span> <span style="font-size: 12pt;"><a href="https://blog.csdn.net/akak2010110/article/details/80953370" style="font-size: 12pt; font-weight: bold;">UGUI drawcall合并-CSDN博客</a></span></div><div><span style="font-size: 12pt;">将同一Canvas下多个UI的网格合并在一起，如果其中任何一个元素的材质、网格顶点、位置(Transform)甚至颜色或者在该Canvas下动态创建或删除UI元素都将导致该Canvas重新计算合批(需要注意的是仅仅会影响这一个Canvas，子Canvas或父Canvas以及其他Canvas不会重新计算)，重新生成新的网格，这个重新计算生成网格的过程被称为rebuild。所以，这也是为什么做UI提倡动静分离(动态部分和静态部分分别用不同的Canvas)，层级尽量减少(层级多了，重新计算更耗时)的原因</span></div><div><img src="Evernote_files/Image [36].png" type="image/png" data-filename="Image.png" style="color: unset; font-family: unset; font-size: unset;"/></div><div>UGUI合批是以Canvas为单位,把满足规则的UI控件合并网格,进行同一个batch</div><div>合并规则: ui控件使用的材质球和贴图需要完全相同才能进行同一batch的渲染</div><div>下图中 文本的贴图和图片的贴图不同所以分在两个batch,渲染先后需要计算</div><div><img src="Evernote_files/Image [37].png" type="image/png" data-filename="Image.png" style="color: unset; font-family: unset; font-size: unset;"/></div><div>UI元素渲染过程</div><ol><li><div>排除未激活或者透明度=0的UI,设置detch =-1,表示不渲染</div></li><li><div>深度优先的顺序遍历Canvas下有效的ui元素,计算每个元素的Detch值</div></li><li><div>对元素进行排序,规则: detch升序 &gt; 材质id升序 &gt; 纹理id降序 &gt;ui层级升序</div></li><li><div>判断相邻元素是否能合批 进行渲染</div></li></ol><div><br/></div><div>计算UI元素的Detch值</div><ol><li><div>深度优先遍历每个有效元素,查找是否存在BottomUI</div></li><ul><li><div><span style="background-color: rgb(255, 250, 165); font-weight: bold;-evernote-highlight:true;">* BottomUI </span></div></li><ul><li><div><span style="background-color: rgb(255, 250, 165);-evernote-highlight:true;">UI层级id比当前元素小(即在Hierarchy里在当前元素上层)</span></div></li><li><div><span style="background-color: rgb(255, 250, 165);-evernote-highlight:true;">mesh需要和当前元素有重叠</span></div></li><li><div><span style="background-color: rgb(255, 250, 165);-evernote-highlight:true;">如果有多个元素满足上面两条规则,取和当前元素最临近的那个(层级绝对值最小的那个)</span></div></li></ul></ul><li><div>判断当前元素是否存在底层元素</div></li><ul><li><div>不存在底层元素,<span style="font-weight: bold;">detch = 0;</span></div></li><li><div>存在底层元素,判断是否能合批(这里只是测试能否合批,没有进行真正的合批)</div></li><ul><li><div>能合批, detch =BottomUI的detch</div></li><li><div>不能合批, detch =BottomUI的detch + 1</div></li></ul></ul></ol><div><img src="Evernote_files/Image [38].png" type="image/png" data-filename="Image.png"/></div><div><span style="font-size: 12pt; font-weight: bold;">合批特殊例子 </span></div><div>先给结论: <span style="background-color: rgb(255, 250, 165);-evernote-highlight:true;">能否合批取决于元素在visiableList中的排序;如果相邻即使某个元素存在bottomUI也可以合批</span></div><div>没有纹理的两个图片,由于img2存在bottomUI(Text),所以会合批失败<img src="Evernote_files/Image [39].png" type="image/png" data-filename="Image.png"/></div><div>但是将两个图片,赋予一样的纹理贴图,img1和img2会合批;</div><div>原因是 img1 和 text 的depth =0; img2 的depth = 1; 但是深度值相同时,会比较其他参数(本次由纹理id决定),导致visible的顺序为 : text img1 img2; 在执行渲染时img1会查找相邻的元素判断能否合批;恰好img1和img2的材质纹理都相同所以合批成功了 </div><div><img src="Evernote_files/Image [40].png" type="image/png" data-filename="Image.png"/></div><div><br/></div><div>优化UI</div><ul><li><div>UI动静分离(比如跟随场景物体的UI 和 普通界面ui在不同的canvas上展示)</div></li><li><div>避免频繁的增删元素,ui层次的结构变化会引起canvas更新</div></li><li><div>避免元素数目过多和层次结构过于复杂,这样影响Batch更新速度</div></li><li><div>尽量不要使用Mask（其内部使用了模板缓冲，至少会造成增加2个Draw Call）</div></li></ul><div><br/></div><div><br/></div><div><span style="font-size: 12pt; font-weight: bold;">Mask 和 RectMask2D </span></div></div><div><span style="font-size: 16px; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; color: rgb(51, 51, 51); font-family: &quot;Helvetica Neue&quot;, Helvetica, &quot;Segoe UI&quot;, Arial, freesans, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">遮罩，顾名思义是一种可以掩盖其它元素的控件。常用于修改其它元素的外观，或限制元素的形状。比如ScrollView或者圆头像效果都有用到遮罩功能。</span></div><div><span style="font-size: 12pt; font-weight: bold;">Mask</span></div><div>使用 GPU 的模板缓冲区来实现遮罩。第一个遮罩元素将 1 写入模板缓冲区。 遮罩下面的所有元素在渲染时进行检查<span style="text-decoration: underline;">，仅渲染到模板缓冲区中有 1 的区域</span>。</div><div>工作流程:</div><ol><li><div style="text-align: start;">Mask会赋予Image一个特殊的材质，这个材质会给Image的每个像素点进行标记，将标记结果存放在一个缓存内（这个缓存叫做 <span style="font-weight: bold;">Stencil Buffer</span>）<span style="color: rgb(83, 88, 97);"><img src="Evernote_files/Image [41].png" type="image/png" data-filename="Image.png"/></span></div></li><li><div style="text-align: start;"><span style="color: rgb(83, 88, 97);">当子级UI进行渲染的时候会去检查这个 Stencil Buffer内的标记，如果当前覆盖的区域存在标记（即该区域在Image的覆盖范围内），进行渲染，否则不渲染</span></div></li></ol><div><br/></div><div>Mask组件在绘制自身时会产出2个drawCall,一个在绘制元素前修改模板缓冲的值;另一个在绘制完成后将模板缓冲的里的值复原(避免影响后续的渲染)<img src="Evernote_files/Image [42].png" type="image/png" data-filename="Image.png"/></div><div><span style="font-weight: bold;">Mask合批探究</span></div><ol><li><div>相同材质相同纹理且没有重叠的情况下,mask可以进行合批(设置模板缓冲在同一个batch; 复位模板缓冲在另一个batch); 重叠会改变detch导致合批失败<img src="Evernote_files/Image [43].png" type="image/png" data-filename="Image.png"/></div></li><li><div>mask内外部元素不能进行合批<img src="Evernote_files/Image [44].png" type="image/png" data-filename="Image.png"/></div></li></ol><div>```Mask套娃不能超过8层,超过的部分遮罩失效</div><div><span style="font-size: 12pt; font-weight: bold;">RectMask2D</span></div><div>遮罩将子元素限制为父元素的矩形</div></div><div>工作流程:</div><ol><li><div>C#:找出父物体中所以RectMask2D覆盖区域的交集</div></li><li><div>C#:将子物体中所有继承MaskGraphic组件的元素调用方法setClipRect(设置裁剪区域),传递给shader</div></li><li><div>shader: 接收到clipRect,在片元着色器中判断片元是否在区域内,不在则将透明度设置为0</div></li><li><div>shader:舍弃透明度小于0,001的元素</div></li></ol><div>概括起来就是先将那些不在其矩形范围内的元素透明度设置为0，然后通过Shader丢弃掉透明度小于0.001的元素</div><div><span style="font-weight: bold;">RectMask合批探究</span></div><ol><li><div>两个RectMask裁剪区域不同时不能进行合批<img src="Evernote_files/Image [45].png" type="image/png" data-filename="Image.png"/></div></li><li><div>rectMask内外部元素不能进行合批</div></li><li><div>RectMask没有CanvasRender组件,不能看做任何ui元素的BottomUI</div></li></ol><div><span style="font-size: 20px; color: green; font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, SimHei, Arial, SimSun; font-variant-ligatures: no-common-ligatures; font-weight: bold;">两者区别:</span></div><div><span style="box-sizing: border-box; outline: 0px; overflow-wrap: break-word; font-size: 16px; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; color: rgb(77, 77, 77); font-family: -apple-system, &quot;SF UI Text&quot;, Arial, &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, &quot;WenQuanYi Micro Hei&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: no-common-ligatures; font-weight: bold;">Mask主要处理不规则图形遮罩效果;</span><span style="font-size: 16px; color: rgb(77, 77, 77); font-family: -apple-system, &quot;SF UI Text&quot;, Arial, &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, &quot;WenQuanYi Micro Hei&quot;, sans-serif; font-variant-ligatures: no-common-ligatures; font-weight: bold;">RectMask2D只能做矩形遮罩.</span></div><div><span style="font-size: 12pt;"><a href="https://duanyiliang.com/2020/11/05/unity_particlesystem_mask/" style="font-size: 12pt; font-weight: bold;">UI上的特效的裁剪问题 | 一点心得</a></span></div><div><span style="font-size: 20px; color: green; font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, SimHei, Arial, SimSun; font-variant-ligatures: no-common-ligatures; font-weight: bold;">总结 :</span></div><ol><li><div>如果界面只需要一个遮罩, 推荐使用RectMask2D,</div></li><li><div>如果界面需要多个遮罩, 根据情况分析, 看多个遮罩之间能否合批, 如果可以则可以考虑使用Mask.</div></li></ol><div><br/></div></div><h3 style="margin: 10px 0px; padding: 0px; font-size: 16px; box-sizing: border-box; position: relative; letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255);"><span style="font-size: 16px; box-sizing: border-box; position: relative; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; color: rgb(51, 51, 51); font-family: &quot;Helvetica Neue&quot;, Helvetica, &quot;Segoe UI&quot;, Arial, freesans, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: bold; line-height: 1.5;">粒子系统实现遮罩效果 - </span> <span style="font-size: 16px; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; color: rgb(51, 51, 51); font-family: &quot;Helvetica Neue&quot;, Helvetica, &quot;Segoe UI&quot;, Arial, freesans, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: bold; line-height: 1.5;">SpriteMask</span></h3><div><span style="letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal;"><span style="font-size: 10pt; color: rgb(51, 51, 51); font-variant-caps: normal; font-variant-ligatures: normal;">SpriteMask的原理和Mask相同都是基于模板测试实现的</span></span></div><div><span style="letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal;"><span style="font-size: 10pt; color: rgb(51, 51, 51); font-variant-caps: normal; font-variant-ligatures: normal;">ui上的粒子特效不能被Mask和RectMask2d裁剪:</span></span></div><ol><li><div><span style="font-size: 10pt; color: rgb(51, 51, 51);">RectMask的是针对于UGUI模块,只渲染目标区域对象(</span> <span style="letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; font-size: 10pt; color: rgb(85, 85, 85); font-variant-caps: normal; font-variant-ligatures: normal;">IClippable 接口</span><span style="font-size: 10pt; color: rgb(51, 51, 51);">);粒子系统不能效果</span></div></li><li><div><span style="font-size: 10pt; color: rgb(51, 51, 51);">Mask的模板测试在最后会重置模板缓冲里的数据导致粒子不渲染</span></div></li></ol><div><span style="font-size: 10pt;">使用spriteMask实现粒子遮罩</span> <a href="https://blog.csdn.net/weixin_43945590/article/details/121566027">粒子特效遮罩 UGUI SpriteMask-CSDN博客</a></div><ol><li><div>ui摄像机 正交视角 cullingMask只选UI标签</div></li><li><div>Canvas 模式选择Screen Space - camera,并将ui摄像机绑定</div></li><li><div>在Canvas下创建空物体挂上SpriteMask且选择一张图片</div></li><li><div>在Canvas下创建粒子系统,Randerer选项中Masking 项选择Visible inside Mask</div></li></ol><div><span style="font-size: 12pt; color: rgb(51, 51, 51); font-family: &quot;Helvetica Neue&quot;;"><img src="Evernote_files/Image [46].png" type="image/png" data-filename="Image.png"/></span><span style="font-size: 12pt; color: rgb(51, 51, 51); font-family: &quot;Helvetica Neue&quot;;"><img src="Evernote_files/Image [47].png" type="image/png" data-filename="Image.png"/></span><span style="font-size: 12pt; color: rgb(51, 51, 51); font-family: &quot;Helvetica Neue&quot;;"><img src="Evernote_files/Image [48].png" type="image/png" data-filename="Image.png" width="434"/></span></div><div><span style="font-size: 12pt;"><br/></span></div><div><span style="font-size: 16px; box-sizing: border-box; position: relative; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal;"><br/></span></div><div><br/></div></div><div><br/></div></span>
</div>
<hr>
<a name="625"/>

<div>
<span><div><div><font style="font-size: 16pt;"><span style="font-size: 16pt; font-weight: bold;">YooAsset 资源加载框架</span></font></div><div>安装yooAsset - 2.2.2-preview</div><div><a href="Evernote_files/YooAsset-dev.zip"><img src="Evernote_files/129d5d679aa78b10356e62ee21c35e52.png" alt="YooAsset-dev.zip"></a></div><div><span style="font-size: 10pt;">* </span> <span style="letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; font-size: 10pt; color: rgb(28, 30, 33); font-family: system-ui, -apple-system, &quot;Segoe UI&quot;, Roboto, Ubuntu, Cantarell, &quot;Noto Sans&quot;, sans-serif, BlinkMacSystemFont, &quot;Segoe UI&quot;, Helvetica, Arial, sans-serif, &quot;Apple Color Emoji&quot;, &quot;Segoe UI Emoji&quot;, &quot;Segoe UI Symbol&quot;; font-variant-caps: normal; font-variant-ligatures: normal;">YooAsset依赖于ScriptBuildPipeline（SBP），在PackageManager里找到SBP插件(v2.0.2 +,过低版本api不兼容)安装</span></div><div><span style="letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; font-size: 10pt;">资源运行四种模式</span></div><ul><li><div>编辑器模式-模拟构建清单</div></li><li><div>离线单机模式</div></li><li><div>联机模式</div></li><li><div>webGL模式</div></li></ul><div>主类YooAssets 存放ResourcePackage列表,一个ResPag就是一个资源的逻辑管理类:</div><ul><li><div>使用资源名做为唯一标识; 主要三大组件</div></li><ul><li><div>ResMgr-负责资源加载卸载面向资源调用方</div></li><li><div>IBundleQuery - 资源加载到游戏的前置检查; 用于检查资源合法性以及资源依赖. 清单查询接口 : 获取资源包信息(BundleInfo), 获取资源包的依赖包信息,判断资源清单是否有效等功能</div></li><li><div>IPlayMode - 资源更新接口: 更新版本,更新清单,更新资源;下载/解压/导入/清空文件</div></li></ul><li><div>IBundleQuery 和 IPlayMode 抽象成接口是因为资源运行有四种模式;不同模式下资源前置检查以及资源更新的实际逻辑不同</div></li><li><div><span style="font-weight: bold;">PlayModeImpl</span> - 继承了IBundleQuery和IPlayMode</div></li></ul><div><br/></div><div><br/></div><div>运行流程</div><ol><li><div>初始化资源包并确定当前资源包的版本:需要确定资源运行模式,依据不同的模式设置不同的资源获取参数</div></li><ul><li><div>创建ResourcePackage,依据资源运行模式进行赋予不同的IBundleQuery和IPlayMode;这个过程是异步的,构建一个<span style="font-weight: bold;">PlayModeImpl(详解于下文)</span></div></li><li><div>初始化三大组件;其中PlayerModelmpl(IBundleQuery和IPlayMode的实现类)的初始化过程是异步的-执行文件系统的创建和初始化</div></li></ul><li><div>校验并更新资源版本号: 获取游戏中资源包类并且执行版本号更新(联机模式和WebGL模式需要向服务请求信息)</div></li><ul><li><div>执行IPlayModel中的请求最新资源版本方法,异步操作返回的是string</div></li></ul><li><div>更新资源清单</div></li><ul><li><div>向远端请求并更新清单,在更新前清理ResMgr的下载器</div></li><li><div>执行IPlayModel中的请求远端资源清单方法:流程为 1检查版本信息是否存在 2检查PlayerModelmpl中的清单版本号是否和最新的版本号一致3.获取最新的清单信息(异步)并更新到PlayerModelmpl</div></li><li><div>远端获取清单文件流程: 1.通过版本号请求清单文件的哈希值 2.通过哈希值请求清单文件的序列化数据(byte[]) 3.解析序列化文件:</div></li><ul><li><div>校验待解析的序列化文件的文件标记,文件版本(并非资源版本)是否和YooAssetSettings里的配置一致;构建清单文件(packageManifest)类</div></li><li><div>读取文件配置写入packageManifest中: 文件配置下图所示<img src="Evernote_files/Image [49].png" type="image/png" data-filename="Image.png"/></div></li><li><div>解析<span style="text-decoration: underline;">资源</span>PackageAsset列表:</div></li><ul><li><div>确定资源包数量,在清单类中创建包信息(PackageAsset)列表,字典和寻址字典<img src="Evernote_files/Image [50].png" type="image/png" data-filename="Image.png"/></div></li><li><div>寻址字典分为两个:1.Location字典: 原始Location路径为key保存PackageAsset信息 2.GUID字典: 资源GUID为Key保存保存PackageAsset信息</div></li><ul><li><div>location字典大小是资源总量的2-3倍;每份资源正常会将PackageAsset里的AssetPath作为key存入以及将AssetPath里的拓展名信息剔除存入;<span style="font-weight: bold;">另外如果清单配置中启用了可寻址资源定位选项会将PackageAsset里的Address作为key存入</span>;一共三份数据</div></li><li><div>GUID字典:将 PackageAsset里的AssetGUID作为key存入</div></li></ul></ul><li><div>解析<span style="text-decoration: underline;">资源包</span>PackageBundle列表; PackageBundle是AssetBundle包详细信息的存储类包括:哈希值,校验码(CRC),文件大小,依赖ID集合,GUID等属性</div></li><ul><li><div>解析序列化文件,实例化 <span style="font-size: medium; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; color: rgb(0, 0, 0); font-family: 微软雅黑; font-variant-caps: normal; font-variant-ligatures: normal;">PackageBundle类设置相关参数后,存入</span>清单类中</div></li><li><div>清单类提供三种字典,方便获取<span style="font-size: medium; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; color: rgb(0, 0, 0); font-family: 微软雅黑; font-variant-caps: normal; font-variant-ligatures: normal;">PackageBundle,分别是:fileName;bundle;BundleGUID(文件哈希值)</span></div></li></ul></ul><li><div><span style="font-weight: bold;">提供传入资源名就可以获取资源GO的功能,用资源名(Location)寻找</span></div></li><li><div><span style="font-weight: bold;">对比不同模式下,更新清单流程的差异(todo)</span></div></li></ul><li><div>对比文件,获取所有需要更新的文件,建立下载器;<span style="text-decoration: underline;">没有需要更新的文件则结束流程</span></div></li><ul><li><div>先了解下文的 文件系统接口-<span style="font-weight: bold;">IFileSystem</span></div></li><li><div>遍历上个步骤更新完毕的清单文件的BundleList,判断每个packageBundle需要在哪个文件系统中下载(依据是,该资源是否归属于文件系统,且未存在);可传最多三个文件系统进行判断(缓存,交互,内置),同时存在时缓存的优先级最高,内置最低;每个需要下载的packageBundle会创建BundleInfo类(包含packageBundle和所属的fileSystem信息)</div></li><li><div>上个步骤的所有BundleInfo信息会加入<span style="text-decoration: underline;">下载操作类(</span><span style="background-color: rgb(255, 250, 165);-evernote-highlight:true;">DownloaderOperation</span><span style="text-decoration: underline;">)</span>统计下载总量和下载大小</div></li></ul><li><div>注册下载事件,开始下载</div></li><ul><li><div>BundleInfo能自己创建下载任务(携带的IfileSystem中获取)开启下载.下载完成后使用文件系统提供的api写入文件并且在文件系统留下记录,下载类(<span style="background-color: rgb(255, 250, 165);-evernote-highlight:true;">DownloaderOperation</span>)的职责是管理这些BundleInfo下载进度和结果</div></li><li><div>下载类(<span style="background-color: rgb(255, 250, 165);-evernote-highlight:true;">DownloaderOperation</span>)在协程中运行,统计所有下载器的进度,当BundleInfo下载器完成下载后,补充新的BundleInfo下载器开始下载</div></li><li><div>如果所有的下载器都已完成下载，检查是否有失败的下载器，如果有，设置操作状态为失败，更新错误信息，并调用下载错误和下载结束的回调函数。如果没有失败的下载器，设置操作状态为成功，并调用下载结束的回调函数</div></li></ul><li><div>下载成后,比对文件系统,删除未使用的文件</div></li><ul><li><div>对比文件系统 和 清单文件里的资源的GUID是否匹配 : 清单中不存在的GUID就认为是未使用文件</div></li></ul></ol><div><br/></div><div><span style="font-size: 14pt; font-weight: bold;">IFileSystem 文件系统接口 :</span> <span style="font-size: 14pt;">负责本地资源版本的检查,更新,解压等功能,这些功能接口很多是配合上文运行流程工作的</span></div><ul><li><div>是PackageBundle的管理接口,功能包括:下载远端资源,加载/卸载Bundle,判断归属/存在,是否需要:下载/解压/导入</div></li><li><div>不同模式下的<span style="font-weight: bold;">PlayModeImpl</span>拥有的文件系统数量不同,通常都是一个,联机模式下存在三个:内置(BuildIn),交互(Delivery),缓存(cache)文件系统</div></li><li><div>派生文件系统默认路径:</div></li><ul><li><div>内置(Buildin): streamAssets文件夹下</div></li><li><div>缓存(Cache): 编辑器模式下放在项目文件夹下;其他平台放在persitentPath文件夹下</div></li><li><div>编辑器(Editor): 自定义路径(必须传)</div></li><li><div>解压(unpack):和缓存文件系统相同;但是重写了保存和临时文件的位置</div></li><li><div>web(web):streamAssets文件夹下</div></li></ul><li><div>PlayModelImpl初始化时会依据传入的文件系统参数,反射创建对应的文件系统(文件系统有附加参数<span style="background-color: rgb(255, 250, 165);-evernote-highlight:true;">FileSystemParametersDefine</span>);</div></li><li><div>内置文件系统-<span style="background-color: rgb(255, 250, 165);-evernote-highlight:true;">DefaultBuildinFileSystem</span></div></li><ul><li><div>在离线模式和联机模式中使用到</div></li><li><div>功能配置:解密服务;文件校验服务; 在构建时传入文件解密类和文件校验等级(只验证文件存在/验证大小/验证大小和CRC) -默认是验证大小</div></li><li><div>初始化:ResourcesPackage -&gt; PlayModelmpl-&gt;IfileSystem;内置文件系统需要依赖两个异步操作:1初始化解压文件系统2加载目录文件</div></li><ul><li><div>解压文件系统实际上是 上文的<span style="font-weight: bold;">缓存(Cache)文件系统</span>;区别是重写了保存目录和根目录</div></li><li><div>加载目录文件:</div></li><ul><li><div>首先通过资源包名和包目录地址(外部传入或者使用YooAssetSettingsData.Setting.DefaultYooFolderName的配置)获取到本地保存的资源清单版本号,依据清单版本信息获取本地保存的序列化清单文件后实例化packageManifest</div></li><li><div>(在编辑器下需要重新构造目录文件信息)使用packageManifest清单类中BundleList所有Bundle的文件名和GUID信息构造成<span style="background-color: rgb(255, 250, 165);-evernote-highlight:true;">DefaultBuildinFileCatalog(SO)</span>资源保存在本地</div></li><li><div>加载本地<span style="background-color: rgb(255, 250, 165);-evernote-highlight:true;">DefaultBuildinFileCatalog</span>资源,从中获取文件的GUID和文件名保存在<span style="text-decoration: underline;">文件系统(IfileSystem)</span>的字典中</div></li></ul></ul></ul><li><div>缓存文件系统 - CacheFileSystem</div></li><ul><li><div>缓存文件系统派生的解压文件系统属于上文的内置文件系统的一个重要模块</div></li><li><div>文件根目录配置: 正常是在persistentData目录下,但是为了方便查看在编辑器下将存储目录放在和Assets同级.       具体目录读取YooAssetSettings.DefaultYooFolderName<img src="Evernote_files/Image [51].png" type="image/png" data-filename="Image.png"/></div></li><li><div>该文件系统初始化流程:</div></li><ul><li><div>确定各种目录:</div></li><ul><li><div>根目录(root)规程依据上文</div></li><li><div>保存资源的目录:root/CacheFiles</div></li><li><div>下载文件时用到的临时目录:root/CacheTempFiles</div></li><li><div>保存清单和程序版本信息的目录:root/ManifestFiles</div></li></ul><li><div>检查程序安装版本号,如果Application,version和本地保存的不一致说明已经覆盖安装了,需要删除root/ManifestFiles目录下的所有内容<img src="Evernote_files/Image [52].png" type="image/png" data-filename="Image.png"/><img src="Evernote_files/Image [53].png" type="image/png" data-filename="Image.png"/></div></li><li><div>获取资源目录文件夹下的所有资源信息,转化为待校验的类放入列表:__data代表资源(AssetBundle),__info代表资源信息(文件CRC码 + 文件大小)<img src="Evernote_files/Image [54].png" type="image/png" data-filename="Image.png"/></div></li><li><div>校验资源信息,<span style="font-weight: bold;">文件校验等级(只验证文件存在/验证大小/验证大小和CRC)</span>,校验通过后将上一步的文件数据转化为FileWrapper类记录到缓存文件系统中,以GUID为Key(上图文件夹名称03)<img src="Evernote_files/Image [55].png" type="image/png" data-filename="Image.png"/></div></li><ul><li><div><span style="font-weight: bold;">文件CRC码: （循环冗余检查码）</span>是一种用于检查文件数据完整性的算法, <span style="text-decoration: underline;">将文件内容作为输入，生成一个短的固定长度码（通常是32位或64位）</span>, 用于检测文件在存储或传输过程中是否被篡改或损坏。如果文件内容发生变化，CRC码也会随之改变，从而可以帮助识别数据错误或损坏。</div></li></ul></ul><li><div>更新资源流程---属于上文的框架运行流程的执行部分</div></li><ul><li><div>校验并更新资源版本号:向远端请求版本号信息(地址和下载远程资源的地址相同)</div></li><li><div>更新资源清单:  本地文件包括数据字节文件和hash校验文件; 下载hash文件-&gt;下载字节文件-&gt;加载hash文件-&gt;加载字节文件<img src="Evernote_files/Image [56].png" type="image/png" data-filename="Image.png"/></div></li><ul><li><div>下载hash文件/字节文件:先尝试读取文件系统root/ManifestFiles下的Hash文件(需要版本号相同,文件名最后带有版本信息),不存在则远程服务器下载(和下载远程资源的地址相同)</div></li><li><div>加载hash文件获取hash值后,对比加载字节文件的MD5码(校验文件一致性)</div></li><li><div>MD5值校验通过后,解析字节文件构建清单文件(packageManifest)类</div></li></ul></ul></ul></ul><div>资源加载流程</div><ul><li><div>PackageManifest数据 json格式如下图</div></li></ul><div><img src="Evernote_files/Image [57].png" type="image/png" data-filename="Image.png"/><img src="Evernote_files/Image [58].png" type="image/png" data-filename="Image.png"/><img src="Evernote_files/Image [59].png" type="image/png" data-filename="Image.png"/></div><ul><li><div>YooAssets维护ResourcePackage列表,以包裹名为key;在游戏初始化阶段需要指定默认包裹,之后的资源默认从该包裹加载;注意每个<span style="font-weight: bold;">ResourcePackage都需要执行上文的初始化流程</span>,才能进行正确的资源获取</div></li><li><div>获取资源可以直接通过资源名称获取,也可以直接传入AssetInfo获取</div></li><ul><li><div>获取<span style="font-weight: bold;">完整资源路径</span>: packageManifest类Mapping1中保存着资源名和完整路径的映射;ResourcePackage类中的PlayMode里保存着清单类<img src="Evernote_files/Image [60].png" type="image/png" data-filename="Image.png"/></div></li><li><div><span style="font-weight: bold;">获取AssetInfo</span>:通过完整的资源路径可以拿到PackageAsset,packageManifest类中的AssetDic保存着资源路径和PackageAsset的映射;<span style="text-decoration: underline; font-weight: bold;">PackageAsset</span>可以构造出AssetInfo</div></li><li><div>使用AssetInfo的完整路径信息进行<span style="font-size: unset; color: unset; font-family: unset;">获取资源管理器中的</span><span style="font-size: unset; color: unset; font-family: unset; font-weight: bold;">ProviderOperation:(</span><span style="font-size: unset; color: unset; font-family: unset;">ResourceManager中缓存着资源提供引用,不会造成多次获取</span><span style="font-size: unset; color: unset; font-family: unset; font-weight: bold;">)</span></div></li></ul><li><div><span style="font-size: 14px; letter-spacing: normal; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(247, 248, 250); color: rgb(51, 51, 51); font-family: tahoma, &quot;Microsoft YaHei&quot;, 微软雅黑, 宋体, &quot;Malgun Gothic&quot;, sans-serif; font-variant: normal; line-height: 26px;">ProviderOperation </span>是资源提供操作的抽象基类,所有提供资源行为都继承自该类:</div></li><ul><li><div>当运行模式为Editor时,使用的是DateBase为前缀的Provider,获取资源的方式为:<span style="text-decoration: underline;">AssetDatabase.LoadMainAssetAtPath/AssetDatabase.LoadAssetAtPath</span></div></li><li><div>其他模式使用的是Bundled为前缀的Provider,获取资源的方式为:<span style="text-decoration: underline;">AssetBundle.LoadAsset/AssetBundle.LoadAssetAsync;</span></div></li><ul><li><div>在获取目标assetbundle前需要先加载依赖资源: 依赖资源的加载实际是加载相关的Bundle列表操作,下文详细展开加载bundle资源策略</div></li><li><div><span style="font-weight: bold;">Q</span>如何获取依赖?<span style="text-decoration: underline;">获取asset的bundle信息再获取bundle的依赖信息</span>;在清单类构造时会依顺序将PackageBundle放入列表中,上文的PackageAsset类中保存着所属BundleId,id对应所属的Bundle在列表的位置;PackageBundle中存放着依赖的id列表(DependIDs);这个数据就是我们需要获取的信息</div></li><li><div>其他模式的加载bundle资源策略: </div></li><ul><li><div>每次执行加载都会执行ProviderOp操作,如果已经加载过直接执行资源完毕回调(执行HandleBase类的回调列表);未加载过则执行</div></li><li><div>每个需要加载的bundle都用 BundleInfo封装,具体加载是由IFileSystem去执行LoadBundleFile</div></li><li><div>ProviderOp中存放着引用计数,执行加载操作计数都会加一,卸载资源操作计数减一;只有引用计数为0才会真正执行IFileSystem中的卸载Bundle文件操作UnLoadBundleFile</div></li></ul></ul></ul></ul><div><br/></div><div><br/></div><div><br/></div><div><br/></div><div><br/></div><div><br/></div><div><br/></div><div><br/></div><div><br/></div><div><br/></div><div><br/></div><div><br/></div></div></span>
</div>
<hr>
<a name="626"/>

<div>
<span><div><div><b><font style="font-size: 14pt;">Unity持久化存储 - PlayerPrefs</font></b></div><div>PlayerPrefs是内置的一个静态类，可以用于存储(键值对)一些简单的数据类型：<span style="background-color: rgb(255, 250, 165);-evernote-highlight:true;">int ,string ,float。</span></div><div><span>各个平台下数据存储位置</span></div><ul><li><div>Windows平台：HKCU\Software\[公司名称]\[产品名称]下注册表内</div></li><li><div>Android平台：/data/data/pkg-name/shared_prefs/pkg-name.xml 中</div></li><li><div>WebGL平台：浏览器的 IndexedDB API 中</div></li><li><div>iOS平台：/Library/Preferences/[Bundle ID].plist 中</div></li></ul><div><br/></div></div></span>
</div>
<hr>
<a name="627"/>

<div>
<span><div><div><div><b><font style="font-size: 18pt;">Unity 资源加载文件夹</font></b></div><div><br/></div><div><b>Asset</b>-项目的根目录文件夹</div><div>加载方法:</div><ul><li><div>编辑器下  <span style="box-sizing: border-box; outline: 0px; overflow-wrap: break-word; font-size: 16px; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; color: rgb(77, 77, 77); font-family: -apple-system, &quot;SF UI Text&quot;, Arial, &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, &quot;WenQuanYi Micro Hei&quot;, sans-serif, SimHei, SimSun; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: bold;">Resources.LoadAssetAtPath(assetsPath) ；</span></div></li><li><div>打包或编辑器下  <span style="box-sizing: border-box; outline: 0px; overflow-wrap: break-word; font-size: 16px; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; color: rgb(77, 77, 77); font-family: -apple-system, &quot;SF UI Text&quot;, Arial, &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, &quot;WenQuanYi Micro Hei&quot;, sans-serif, SimHei, SimSun; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: bold;">AssetDatabase.LoadAssetAtPath(filePath)；</span></div></li></ul><div><span style="font-size: 12pt;"><br/></span></div><div><b>Resources</b> - 用于存放资源的特殊文件夹</div><div>打包时会将Asset目录下所有Resources文件夹合并,并且加密压缩</div><div>打包之后变为ReadOnly</div><div>加载方法:  <span style="box-sizing: border-box; outline: 0px; overflow-wrap: break-word; font-size: 16px; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; color: rgb(77, 77, 77); font-family: -apple-system, &quot;SF UI Text&quot;, Arial, &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, &quot;WenQuanYi Micro Hei&quot;, sans-serif, SimHei, SimSun; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: bold;">Resources.Load(assetsPath)；</span></div></div><div><span style="box-sizing: border-box; outline: 0px; overflow-wrap: break-word; font-size: 16px; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal;"><br/></span></div><div><span style="font-size: 16px; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; color: rgb(79, 79, 79); font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, SimHei, Arial, SimSun; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: bold;">streamingAssets</span></div><div><span style="letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal;"><span style="color: rgb(79, 79, 79); font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, SimHei, Arial, SimSun; font-variant-caps: normal; font-variant-ligatures: normal; font-size: 10pt;">一般是存放预存信息,初始的AssetBundle资源;里边的资源打包时不压缩,运行时只能读</span></span></div><div><span style="letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal;"><span style="color: rgb(79, 79, 79); font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, SimHei, Arial, SimSun; font-variant-caps: normal; font-variant-ligatures: normal; font-size: 10pt;">加载方式 : </span></span> <span style="font-size: 16px; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; color: rgb(77, 77, 77); font-family: -apple-system, &quot;SF UI Text&quot;, Arial, &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, &quot;WenQuanYi Micro Hei&quot;, sans-serif, SimHei, SimSun; font-variant-caps: normal; font-variant-ligatures: normal;">UnityWebRequest</span></div><div><span style="font-size: 12pt; color: rgb(77, 77, 77);">平台路径:</span></div><ul><li><div>安卓  path = &quot;jar:file://&quot; + Application.dataPath + &quot;!/assets/&quot;;</div></li><li><div>ios  path = Application.dataPath + &quot;/Raw&quot;;</div></li><li><div>pc  path = Application.dataPath + &quot;/StreamingAssets&quot;;</div></li></ul><div><span style="font-size: 16px; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal;"><br/></span></div><div><span style="color: rgb(79, 79, 79); font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, SimHei, Arial, SimSun; font-size: 16px; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: bold; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal;">Application.dataPath : </span> <span style="color: rgb(77, 77, 77); font-family: -apple-system, &quot;SF UI Text&quot;, Arial, &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, &quot;WenQuanYi Micro Hei&quot;, sans-serif, SimHei, SimSun; font-size: 16px; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255);">用于返回</span><span style="box-sizing: border-box; outline: 0px; font-synthesis-style: auto; overflow-wrap: break-word; font-family: -apple-system, &quot;SF UI Text&quot;, Arial, &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, &quot;WenQuanYi Micro Hei&quot;, sans-serif, SimHei, SimSun; font-size: 16px; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255); color: rgb(243, 59, 69);">工程文件所在位置的数据文件夹</span><span style="color: rgb(77, 77, 77); font-family: -apple-system, &quot;SF UI Text&quot;, Arial, &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, &quot;WenQuanYi Micro Hei&quot;, sans-serif, SimHei, SimSun; font-size: 16px; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal;">的路径</span></div><div><span style="color: rgb(79, 79, 79); font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, SimHei, Arial, SimSun; font-size: 16px; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: bold; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal;">Application.streamingAssetsPath :</span> <span style="color: rgb(77, 77, 77); font-family: -apple-system, &quot;SF UI Text&quot;, Arial, &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, &quot;WenQuanYi Micro Hei&quot;, sans-serif, SimHei, SimSun; font-size: 16px; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255);">用于返回</span><span style="box-sizing: border-box; outline: 0px; font-synthesis-style: auto; overflow-wrap: break-word; font-family: -apple-system, &quot;SF UI Text&quot;, Arial, &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, &quot;WenQuanYi Micro Hei&quot;, sans-serif, SimHei, SimSun; font-size: 16px; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255); color: rgb(243, 59, 69);">流数据的缓存目录</span><span style="color: rgb(77, 77, 77); font-family: -apple-system, &quot;SF UI Text&quot;, Arial, &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, &quot;WenQuanYi Micro Hei&quot;, sans-serif, SimHei, SimSun; font-size: 16px; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal;">，返回路径为相对路径，适合设置一些外部数据文件的路径。</span></div><div><span style="color: rgb(79, 79, 79); font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, SimHei, Arial, SimSun; font-size: 16px; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: bold; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal;">Application.persistenDataPath : </span> <span style="color: rgb(77, 77, 77); font-family: -apple-system, &quot;SF UI Text&quot;, Arial, &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, &quot;WenQuanYi Micro Hei&quot;, sans-serif, SimHei, SimSun; font-size: 16px; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255);">用于返回一个持久化数据存储目录的路径，可以在此路径下</span><span style="box-sizing: border-box; outline: 0px; font-synthesis-style: auto; overflow-wrap: break-word; font-family: -apple-system, &quot;SF UI Text&quot;, Arial, &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, &quot;WenQuanYi Micro Hei&quot;, sans-serif, SimHei, SimSun; font-size: 16px; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255); color: rgb(243, 59, 69);">存储一些持久化的数据文件</span><span style="color: rgb(77, 77, 77); font-family: -apple-system, &quot;SF UI Text&quot;, Arial, &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, &quot;WenQuanYi Micro Hei&quot;, sans-serif, SimHei, SimSun; font-size: 16px; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal;">。应用更新不会擦除此位置文件,多是保持用户信息数据位置  内容可读写,只能在运行时读写</span></div><div><span style="color: rgb(79, 79, 79); font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, SimHei, Arial, SimSun; font-size: 16px; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: bold; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal;">Application.temporaryCachePath: </span> <span style="color: rgb(77, 77, 77); font-family: -apple-system, &quot;SF UI Text&quot;, Arial, &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, &quot;WenQuanYi Micro Hei&quot;, sans-serif, SimHei, SimSun; font-size: 16px; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255);">用于返回一个</span><span style="box-sizing: border-box; outline: 0px; font-synthesis-style: auto; overflow-wrap: break-word; font-family: -apple-system, &quot;SF UI Text&quot;, Arial, &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, &quot;WenQuanYi Micro Hei&quot;, sans-serif, SimHei, SimSun; font-size: 16px; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255); color: rgb(243, 59, 69);">临时数据的缓存目录</span><span style="color: rgb(77, 77, 77); font-family: -apple-system, &quot;SF UI Text&quot;, Arial, &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, &quot;WenQuanYi Micro Hei&quot;, sans-serif, SimHei, SimSun; font-size: 16px; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal;">。</span></div><div><span style="font-size: 12pt; color: rgb(77, 77, 77);"><img src="Evernote_files/Image [61].png" type="image/png" data-filename="Image.png"/></span></div><div><span style="font-size: 12pt;"><br/></span></div><div><span style="font-size: 12pt;">Unity</span></div><div><span style="font-size: 12pt;"><br/></span></div><div><br/></div></div></span>
</div>
<hr>
<a name="629"/>

<div>
<span><div><div><div><span style="font-size: 18pt; font-weight: bold;">ALResCore资源管理流程</span></div><div>资源配置(Version)在SteamingAssets文件下:分为Area,game,Plat等,包含版本号和资源路径列表(不一定全都有</div><div><br/></div><ol><li><div>AssetBundleVersionDownloadDealer ab包版本下载</div></li><ul><li><div>使用协程</div></li><li><div>从本地请求资源配置pc上在SteamingAssets文件夹下,安卓平台(todo)</div></li><li><div>获取到的资源实际上是SO文件<img src="Evernote_files/Image [62].png" type="image/png" data-filename="Image.png"/></div></li><li><div>获取到配置之后,初始化,自带的AssetBundleLoadMgr</div></li></ul><li><div>AssetBundleLoadMgr资源加载管理对象</div></li><ul><li><div>AssetBundleVersionInfoMgr通过路径为索引存储资源配置(AssetBundleVersionInfo)</div></li><li><div>限定最大下载数,区分必要和非必要的资源,是否使用缓存</div></li><li><div>ALLoadingAssetInfo单项资源下载类,AssetBundleDealer获取到该数据类后进行下载(本地/远程)</div></li><ul><li><div>是否是必要下载资源;是否使用缓存;下载成功回调;下载重试次数</div></li><li><div>Dealer分为两种本地和远端,本地直接使用AssetBundle.LoadField加载,远端使用uwq.GetAssetBundle;两种Dealer分别用在不同的AssetBundleLoadMgr上</div></li></ul><li><div>ALLoadingAssetInfo 是该管理器的主体功能对象,围绕该类进行下载; 下载完成后以小写路径为索引注册进ResourceMgr,并且加入LoadedMgr进行检查</div></li><li><div>-addLoadAssetInfo: 需要下载的Asset由外层ResCore的*加载策略决定,LoadMgr获取到基本参数(路径,是否使用cache,是否必要资源)构造ALLoadingAssetInfo在确认资源未存在的情况下加入待下载集合,如果待下载集合存在该资源信息直接添加回调</div></li><li><div>重下机制</div></li><ul><li><div>开始下载的ALLoadingAssetInfo会存入下载队列,之后无论成失败都会从该队列中移除</div></li><li><div>下载失败,且不超过重试次数时,会将该info放入待下载队列,进行后续下载</div></li></ul><li><div>缓存机制(远程资源)</div></li><ul><li><div>abVersionInfo 中有个HashTag字段;当 使用缓存 时,会在uwq.GetAssetBundle中传入该HashTag</div></li><li><div>原理:如果提供Hash128参数, DownloadHandlerAssetBundle将使用AssetBundle的缓存系统,假如AB已被缓存且不需要重新下载,则直接从缓存中加载</div></li></ul></ul><li><div>ResourceMgr的主体功能是维护AlAssetBundObj的字典,abo由传入的ALLoadingAssetInfo构造生成</div></li><ul><ul><li><div>AlAssetBundObj包含内容:str索引;是否为www加载(区分远端加载和本地加载);加载中的统计数lodingOp(静态对象的Op&gt;0);以及最后一次访问的时间标记(底下展开讨论);</div></li><ul><li><div>对于资源的操作也封装在该类中:load,unload(本地文件加载的assetbundle基本不占用内存，不需要反复的创建和释放)和discard(把场景中的加载出的对象也卸载掉) ;执行unload和discard操作都会反注册ResMgr里自身的数据</div></li></ul></ul><li><div>AssetBundleLoadedMgr已加载的资源对象管理器;按对象最后访问时间决定是否去留(www下载资源)</div></li><ul><li><div>在资源注册进ResMgr后就开始进行分区: index  = 当前时间 / 时间区域跨度</div></li><li><div>每隔一段时间检查一次过期的分区[index_min= (上次检查时间 - 资源无访问最长存活时间) / 时间区域跨度 ; index_max =(当前时间 - 资源无访问最长存活时间) / 时间区域跨度]资源;如果资源的lodingOp &lt; 0则进行释放操作,反之更新资源最后的访问时间</div></li></ul></ul></ol><div><font style="font-size: 16pt;"><span style="font-size: 16pt; font-weight: bold;">ResCore - 游戏中管理远程资源，本地资源以及版本信息等同步的管理对象</span></font></div><div>主要成员:两个资源加载管理对象(RemoteLoadMgr,LocalLoadMgr - 可选不一定都有); 远程加载处理管理器(HttpLoadMgr);依赖管理加载处理器(ResDependMgr);本地补丁信息(LocalPatchInfo)</div><ol><li><div>LocalLoadMgr是管理本地StreamingAssets的资源; RemoteLoadMgr是管理从指定URL下载到PersistenceDataPath目录下的资源</div></li><li><div>依赖管理加载处理器:由于组织各资源打包文件相互依赖的信息;</div></li><ul><li><div>依赖管理器的数据来自一个独立的ab包(__dependence.unity3d),该ab包包含资源依赖关系集合文件ALSOAssetBundleDependenceSet =&gt; List&lt;AssetBundleDependenceInfo&gt;; 依赖管理器将下图数据转化成ALResABDependenceInfo(AssetBundleDependenceInfo + 依赖是否已经加载),用assetPath作为字典的Key<img src="Evernote_files/Image [63].png" type="image/png" data-filename="Image.png"/></div></li></ul><li><div>本地补丁信息(LocalPatchInfo)</div></li><ul><li><div>补丁文件地址在PersistenceDataPath目录/game(refdata)/__al_patch.info里,内容就是AssetBundleVersionInfo的参数:路径:hashTag:版本号:文件大小;读取该文件转换成AssetBundleVersionInfo集合<img src="Evernote_files/Image [64].png" type="image/png" data-filename="Image.png"/></div></li><li><div>LocalPatchInfo 通过路径为索引存储补丁资源配置(AssetBundleVersionInfo);<span style="font-weight: bold;">该补丁资源配置集合用于在ResCore里更新资源(下文展开流程)</span></div></li><li><div>附带本地资源下载管理器AssetBundleLoadMgr</div></li><li><div>ResCore更新资源之后会将_al_patchInfo.info文件内容也更到最新</div></li><li><div>加密文件功能(todo) </div></li></ul><li><div>远程加载处理管理器(HttpLoadMgr) 用于下载远端资源-可并行下载,支持重下</div></li><ul><li><div>ALHttpDownDealer管理每个下载项目,包括 资源URL,包名,临时存放位置,重试次数,包体大小,当前进度,下载回调等</div></li><li><div>每个项目都开启一个线程下载,先下载到临时文件目录;下载成功后会调用ResCore的解压功能将资源解压到正确的位置;</div></li><li><div>网络不稳定,直接退出游戏,下载出异常会视为下载失败,会将临时写入的文件删掉</div></li></ul><li><div><span style="font-weight: bold;">加载资源</span></div></li><ul><li><div>加载资源前会先等待依赖加载管理器初始化完毕后再执行,因为需要获取到该资源的依赖信息</div></li><li><div>获取目标资源的依赖信息,先加载依赖信息的ab资源后再加载目标资源</div></li><li><div><span style="font-weight: bold;">默认加载依赖策略</span>: 最大迭代深度为6,迭代到7时直接开始进行加载操作(下文加载策略)</div></li><li><div><span style="font-weight: bold;">同步加载依赖策略</span>: 使用集合保存待加载的ab包名字信息; 每次迭代时判断集合中是否存在若存在则说明依赖存在闭环直接开始加载</div></li></ul><li><div><span style="font-weight: bold;">*加载资源策略(异步)</span></div></li><ul><li><div>获取最新资源版本信息AssetBundleVersionInfo -&gt; 依据VersionInfo的assetPatth从LoadMgr中下载对应ab包 -&gt; 执行回调Action&lt;bool _isSuc, <span style="font-size: medium; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; color: rgb(0, 0, 0); font-family: 微软雅黑; font-variant-caps: normal; font-variant-ligatures: normal;">AlAssetBundObj _abo</span>&gt;</div></li><li><div>资源加载依据ab包路径,获取资源版本信息AssetBundleVersionInfo;上文提到有三个地方可获取 -远程资源加载管理器 -补丁信息类 -本地资源加载管理器</div></li><ul><li><div>如果存在 远程资源加载管理器,就会优先从remote里获取,如果没有获取到就当作失败处理不进行后续操作</div></li><li><div>补丁信息代表着当前客户端最新的版本配置; 获取补丁信息中该资源的版本配置和remote里获取的配置(如果有)进行对比</div></li><ul><li><div>获取补丁信息失败时(版本信息集合中获取不到),会检查是否存在ab包预设的路径是否存在资源;</div></li><li><div>上一点的补充: 1.当补丁里的资源配置版本号和远端不一致需要删除补丁内的信息2.当本地的ab包不存在时也需要删除补丁内的配置信息<img src="Evernote_files/Image [65].png" type="image/png" data-filename="Image.png"/></div></li><li><div>当补丁配置和remote配置相同,直接使用补丁内置的资源管理器进行资源获取(addLoadAssetInfo);否则对比local配置;此时版本相同直接使用localLoadMgr;否则说明本地和补丁配置都是落后的;<span style="text-decoration: underline;">需要开启下载remote信息并且更新补丁数据(下面展开)</span></div></li></ul><li><div>不存在补丁信息时,获取本地资源管理器中的版本配置信息和remote里获取的配置进行对比,一致?local:remote;添加到对应管理器的资源待加载队列中;待加载完毕执行回调</div></li></ul><li><div>请求远端VersionInfo并更新补丁数据流程</div></li><ul><li><div>需要明确的是,加载资源策略是针对单个Ab包的;所以versionInfo更新也是更新单条内容</div></li><li><div>使用ResCore自带的远程加载处理管理器(HttpLoadMgr)进行下载远端</div></li><li><div>下载的文件是单独的最新ab包资源(需要解压),需要额外添加到LocalPatchInfo的资源配置字典(内存)以及__al_patch.info里(本地)</div></li></ul></ul><li><div>CompleteResCore - 派生于ResCore</div></li><ul><li><div>*更新所有资源操作</div></li><ul><li><div>前置条件是保证存在 LocalPatchInfo 和 remoteLoadMgr</div></li><li><div>遍历远端资源信息(remoteLoadMgr.versionMgr中获取),判断补丁中的配置哪些需要删除,哪些需要更新</div></li><ul><li><div>哪些需要删除?补丁表中存在但是远端不存在的配置需要删除</div></li><li><div>补丁信息不存在,本地信息也不存在或者版本不一致 - 需要更新</div></li><li><div>补丁信息存在,但是资源不存在-需要更新</div></li><li><div>补丁信息存在,版本号和远端不一致 - 需要跟新</div></li><li><div>资源更新的同时需要将补丁信息一并更新</div></li></ul><li><div>计算总更新资源大小(abVersionInfo存在资源size信息)</div></li><li><div>删除补丁中需要删除的配置以及对应的资源</div></li><li><div>用压缩包的方式下载ab资源,完毕后更新补丁资源配置信息</div></li></ul></ul></ol><div><br/></div><div>ResCore工作流程</div><div>ResCore主要成员:两个资源加载管理对象(RemoteLoadMgr,LocalLoadMgr - 可选不一定都有); 远程加载处理管理器(HttpLoadMgr);依赖管理加载处理器(ResDependMgr);本地补丁信息(LocalPatchInfo)</div><div>LoadMgr主要成员:VersionMgr(资源版本管理器) ResMgr(下载资源管理对象)</div><ol><li><div>指定当前ResCore属于哪种类型: 将文件夹名字传入路径提供器,路径提供器会依据文件夹名字映射出资源实际路径</div></li><li><div>初始化本地资源版本信息 - LoadMgr里的VersionMgr依据路径提供器提供的地址使用uwq.getAssetBundle获取名为Version的资源包</div></li><li><div>初始化补丁信息 - 用PersistenceDataPath目录下_al_patch.Info初始化补丁里的资源信息</div></li><li><div>初始化远端资源版本信息 - 使用CDN( <span style="font-size: 14px; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: pre-wrap; background-color: rgb(243, 245, 249); color: rgb(10, 191, 91); font-family: Consolas, &quot;Liberation Mono&quot;, Menlo, Courier, &quot;Microsoft Yahei&quot;, monospace; font-variant-caps: normal; font-variant-ligatures: normal;">Content Delivery Network</span>) 内容分发网络技术 获取服务器上最新的资源版本信息</div></li><li><div>三方版本校验 - 上文第7点</div></li><li><div>下载最新资源到PersistenceDataPath对应目录下,并且更新patch.info的内容</div></li></ol><div>加载指定资源流程</div><ol><li><div>加载资源前会判断ResCore里的资源依赖管理器是否初始化完成</div></li><li><div>获取依赖关系,先加载最新的依赖包资源</div></li><li><div>依赖包加载完毕之后加载目标资源包</div></li><li><div>资源先在RescourceMgr中检查是否在内存中</div></li><li><div>不在内存中则通过LoadMgr加载,并且注册进ResMgr中以便复用资源</div></li></ol><div><br/></div><div><br/></div></div><hr/><div>二次回顾</div><ol><li><div>资源管理系统的初始化流程?</div></li><ol><li><div>初始化版本信息,分为两种方式,本地获取和远端请求version的ab包 - 都是使用uwq.GetAssetBundle;获取的内容是ab包路径和对应版本信息,文件大小</div></li><ul><li><div>初始化ALPatchInfo(本地缓存),从presisten目录下的AL_patch文件中解析文本获取版本信息</div></li><li><div>初始化随包的版本信息,从streamingAsset目录下获取_version的AB包解析获取版本信息</div></li><li><div>初始化远端的版本信息,从服务器获取_version的AB包解析获取版本信息</div></li></ul><li><div>获取AssetBundle,加载进内存中并在ResMgr上注册</div></li><li><div>在加载资源前,会先判断是否进行依赖资源加载,</div></li><li><div><br/></div></li></ol><li><div>资源管理系统包含哪些重要的模块?</div></li></ol><div><br/></div><div><br/></div></div><div><br/></div></span>
</div>
<hr>
<a name="638"/>

<div>
<span><div><div><span style="font-size: 16pt; font-weight: bold;">无限滚动列表</span></div><div>主要依赖于动态加载和卸载列表项，以便在用户滚动时保持良好的性能;支持水平布局和垂直布局</div><div>初始化:</div><ol><li><div>获取CellItem预制体信息,规范预制体的锚点(anchor)和支点(Pivot)</div></li><ul><li><div>无论是水平还是垂直布局,CellItem的支点都是左上角(0,1)</div></li><li><div>锚点需要区分是垂直还是水平布局: anchorMin 代表锚点左下角位置, anchorMax代表右上角位置</div></li><ul><li><div>垂直布局时:判断锚点是否在顶部;不在顶部时需要矫正到顶部min(0,1) max(1,1)</div></li><li><div>水平布局时:判断锚点是否在左侧;不在左侧时需要矫正到左下角mian(0,0) max(0,1)</div></li><li><div>调整完锚点之后,将anchoredPosition(锚点偏移位置)设为0</div></li></ul></ul><li><div>记录CellItem的尺寸,ScrollRect的Rect,展示区域Content的Rect;<span style="font-weight: bold;">并将Content的支点设置在左上角</span></div></li><li><div>给ScrollRect添加滑动事件,<span style="font-weight: bold;">检查item显隐和展示向上滑动向下滑动提示</span></div></li></ol><div>设置数据: CellInfo记录了Go和当前位置信息;保存一个CellInfo数据,依据index获取CellInfo信息</div><ol><li><div>计算Content的尺寸</div></li><ul><li><div>垂直布局 :高度-(间距 + cell高度) * 向上取整(总数量 / 行数)  宽度-相对于锚点的宽度增量(sizeDelta.x<span style="font-weight: bold;">)因为锚点在左上角,取x的增量就能表示正确的宽度</span>;需要注意最小不能小于之前Content的尺寸</div></li><li><div>水平布局:宽度-(间距 + cell宽度) * 向上取整(总数量 / 行数) 高度-相对于锚点的高度增量(sizeDelta.y);需要注意最小不能小于之前Content的尺寸</div></li></ul><li><div><span style="font-weight: bold;">***计算显示区域中的开始索引和结束索引</span></div></li><ul><li><div>需要依据当前Scroll的位置(normalPosition)进行推算:</div></li><ul><li><div>从左到右0-1 <span style="font-weight: bold;">当前scroll的位置 = 当前Content的偏移量(视图左侧 - 内容左侧) / 总宽度(内容总宽度 -  视图总宽度) ;</span></div></li><li><div>从上到下1-0(锚点在左上);计算垂直布局的时候需要使用1-postion; <span style="font-weight: bold;">当前scroll的位置 = 当前Content的偏移量(视图底侧 - 内容底侧) / 总高度(内容总高度 -  视图总高度) ;</span></div></li></ul><li><div><span style="font-size: 14px; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: pre-wrap; background-color: rgb(210, 249, 209); color: rgb(0, 0, 0); font-family: v-sans, system-ui, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, sans-serif, &quot;Apple Color Emoji&quot;, &quot;Segoe UI Emoji&quot;, &quot;Segoe UI Symbol&quot;; font-variant-caps: normal; font-variant-ligatures: normal;">anchoredPosition 是什么?</span> <span style="font-size: 14px; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: pre-wrap; background-color: rgb(244, 246, 248); color: rgb(36, 41, 47); font-family: -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, &quot;Noto Sans&quot;, Helvetica, Arial, sans-serif, &quot;Apple Color Emoji&quot;, &quot;Segoe UI Emoji&quot;; font-variant-caps: normal; font-variant-ligatures: normal;">它表示相对于父容器的锚点（anchor）的偏移量。</span></div></li><li><div>垂直布局: 由于是从底部开始计算的,所以 开始索引 = (<span style="font-weight: bold;">1 -</span> <span style="font-weight: bold;">content的偏移量</span>)/<span style="font-weight: bold;">元素的单个宽度后 * n(表示一行n个);</span> 结束索引 = (<span style="font-weight: bold;">1 -</span> <span style="font-weight: bold;">content的偏移量</span>) + 视图高度 / <span style="font-weight: bold;">元素的单个宽度后 * n(表示一行n个)</span></div></li><li><div>水平布局: 开始索引 =( <span style="font-weight: bold;">content的偏移量 / 元素的单个宽度 ) * n(表示一列n个)</span>;还需要考虑一列多个的情况; 结束索引 = content的偏移量 + 视图的宽度 / 元素单个宽度,也是需要考虑一列多个的情况</div></li><li><div><span style="font-size: 12pt; font-weight: bold;">**知道了计算水平和垂直布局就可以反向推出moveto的实现方式:  偏移量 / 可移动范围(内容尺寸 - 视图尺寸) </span></div></li><li><div><span style="font-size: 12pt;"><span style="font-size: 12pt; font-weight: bold;"><img src="Evernote_files/Image [66].png" type="image/png" data-filename="Image.png"/></span></span></div></li></ul><li><div>更新所有元素:处于开始和结束索引区间的元素显示并且更新位置,否则隐藏;</div></li><ul><li><div><span style="font-weight: bold;">*更新每个Item的坐标</span></div></li><ul><li><div>垂直布局:  x = (cell宽度 + 间距) * (当前索引 <span style="font-weight: bold;">%</span> 行数)     y = (cell高度 + 间距) * 向下取整(当前索引 / 行数)</div></li><li><div>水平布局:  x = ((cell宽度 + 间距) * 向下取整(当前索引 / 列数)     y =  (cell高度 + 间距) * (当前索引 <span style="font-weight: bold;">%</span> 列数)</div></li><li><div>将计算出来的位置更新到当前索引对应的CellInfo中</div></li></ul></ul></ol><div><span style="font-weight: bold;">如何判断元素是否在显示范围,,除了整体计算开始和结束索引的方式还可以使用判断位置的方式</span></div><ul><li><div>垂直布局: 获取content的锚点y值偏移量作为是否可见的<span style="font-weight: bold;">基准点</span>判断依据: 当前item的y 向下移动一个item的高度的距离还比<span style="font-weight: bold;">基准点</span>大说明在content上方不显示; 当前item的y 向上移动mask的高度值还在基准点下方说明在content下方不显示</div></li><li><div>水平布局: 获取content的锚点x值偏移量作为是否可见的<span style="font-weight: bold;">基准点</span>判断依据: 当前item的x 向右移动一个item的宽度的距离还比基准点小说明在content左边不显示; 当前item的x 向左移动mask的宽度还在基准点的右边说明在content右边不显示</div></li><li><div>如果属于显示范围中展示该item和之前记录的首尾index作对比更新,在范围之外的话隐藏item</div></li></ul><div><br/></div><div><br/></div></div><div><br/></div></span>
</div>
<hr>
<a name="646"/>

<div>
<span><div><div>ILRunTime问题汇总</div><ol><li><div>跨域继承非mono的类型, 迭代器内存入字典后使用<b>TryGet</b>出现 System.InvalidCastException: Specified cast is not valid.错误</div></li></ol><div style="box-sizing: border-box; padding: 8px; font-family: Monaco, Menlo, Consolas, &quot;Courier New&quot;, monospace; font-size: 12px; color: rgb(51, 51, 51); border-radius: 4px; background-color: rgb(251, 250, 248); border: 1px solid rgba(0, 0, 0, 0.15);-en-codeblock:true;"><div>会报错 if (_m_giftPageDic.TryGetValue((int) _tabType, out GGUIWndInfinitePackGiftPage page) &amp;&amp; page != null)</div></div><div style="box-sizing: border-box; padding: 8px; font-family: Monaco, Menlo, Consolas, &quot;Courier New&quot;, monospace; font-size: 12px; color: rgb(51, 51, 51); border-radius: 4px; background-color: rgb(251, 250, 248); border: 1px solid rgba(0, 0, 0, 0.15);-en-codeblock:true;"><div>在热更工程里添加字典的拓展方法,却不会报错???</div><div>public static V hotfixTryGetValue&lt;K, V&gt;(this IDictionary&lt;K, V&gt; _dict, K _key)</div><div>{</div><div>    V value = default(V);</div><div>    if (_dict == null)</div><div>        return value;</div><div><br/></div><div><br/></div><div>    if (_key == null)</div><div>        return value;</div><div><br/></div><div><br/></div><div>    _dict.TryGetValue(_key, out value);</div><div>    return value;</div><div>}</div></div><div>估计是重定向导致的,之后再探究</div></div></span>
</div>
<hr>
<a name="648"/>

<div>
<span><div><div><div> C#解惑</div><ul><li><div>在构造函数内调用虚方法</div></li></ul><div><span style="font-weight: bold;">基类构造函数的执行要早于子类构造函数</span></div><div><span style="font-weight: bold;">基类构造函数中对于虚方法的调用，实际调用的是子类中重写的虚方法</span></div><div>基于以上两点原因, 在代码中保证那些可能会被继承的实体，在子类中重写那些虚方法时，不要依赖于子类自身的构造函数</div><div><br/></div></div><ul><li><div><span style="font-size: 14pt; font-weight: bold;">协变\逆变 - </span></div></li></ul><div><span style="font-size: 15px; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; color: rgb(51, 51, 51); font-family: &quot;Microsoft YaHei&quot;; font-variant-caps: normal; font-variant-ligatures: normal;">协变</span><span style="font-size: 15px; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; color: rgb(51, 51, 51); font-family: &quot;Microsoft YaHei&quot;; font-variant-caps: normal; font-variant-ligatures: normal;">指能够使用比原始指定的派生类型的派生程度更大（更具体的）的类型，</span></div><div><span style="font-size: 15px; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; color: rgb(51, 51, 51); font-family: &quot;Microsoft YaHei&quot;; font-variant-caps: normal; font-variant-ligatures: normal;">逆变</span><span style="font-size: 15px; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; color: rgb(51, 51, 51); font-family: &quot;Microsoft YaHei&quot;; font-variant-caps: normal; font-variant-ligatures: normal;">指能够使用比原始指定的派生类型的派生程度更小（不太具体的）的类型。</span><a href="https://docs.microsoft.com/zh-cn/dotnet/standard/generics/covariance-and-contravariance" style="font-size: 15px; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; border-bottom: 1px dotted rgb(51, 51, 51); color: rgb(0, 0, 255); font-family: &quot;Microsoft YaHei&quot;; font-variant-caps: normal; font-variant-ligatures: normal;">[MSDN]</a> </div><div><span style="font-size: 14px; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal;"><span style="font-size: 14px; color: rgb(51, 51, 51); font-family: verdana, Arial, Helvetica, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; text-decoration: underline;">派生程度小可以理解为基类，派生程度大可以理解为子类或派生类</span></span></div></div><div><span style="font-size: 14px; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal;"><span style="font-size: 14px;">应用于委托和接口, in 表示逆变 out 表示协变 </span></span></div><div><br/></div></span>
</div>
<hr>
<a name="669"/>

<div>
<span><div><div><span style="font-size: 16pt; font-weight: bold;">unity EventSystem</span></div><div><span style="font-size: unset; color: unset; font-family: unset;">ugui点击事件调用 : </span></div><ol><li><div> 射线检测,获取到所有能接收到射线的物体 (Raycat target选项关闭,隐藏物体 不能接收);获取排序第一个的物体 (GraphicRaycaster里 2d元素优先级高于3d)</div></li><li><div>获取当前元素的IPointClickHandler接口;如果不存在就会向上级父节点获取(隐藏状态不会获取),直到获取到点击事件接口</div></li><li><div>当执行到输入系统的鼠标释放方法时,会执行上一步获取的go的所有点击事件接口;不会向上传递</div></li></ol><div>UGUI实现事件的方式:</div><ol><li><div>MonoBehaviour继承IEventSystemHandler接口</div></li><li><div>手动在Insprector面板/代码上添加EventTrigger, EventTrigger是继承了所有事件接口的组件</div></li><li><div>处于性能考虑,EventTrigger接受了所有的事件; 应该编写自己的事件监听脚本<img src="Evernote_files/Image [67].png" type="image/png" data-filename="Image.png" width="717"/></div></li></ol><div>按键导航效果ISelectHandler</div><div style="box-sizing: border-box; padding: 8px; font-family: Monaco, Menlo, Consolas, &quot;Courier New&quot;, monospace; font-size: 12px; color: rgb(51, 51, 51); border-radius: 4px; background-color: rgb(251, 250, 248); border: 1px solid rgba(0, 0, 0, 0.15);-en-codeblock:true;"><div>using UnityEngine;</div><div>using UnityEngine.EventSystems;</div><div>using UnityEngine.UI;</div><div>public class Navigation : MonoBehaviour, ISelectHandler</div><div>{</div><div>    public Button nextButton;</div><div>    public void OnSelect(BaseEventData eventData)</div><div>    {</div><div>        EventSystem.current.SetSelectedGameObject(nextButton.gameObject);</div><div>    }</div><div>}</div></div><div><br/></div><div><span style="font-size: 16pt; font-weight: bold;">EventSystem工作流程:</span></div><div>inputModule接收用户输入 -&gt; RayCaster根据用户数据找到目标物体 -&gt; 根据事件类型调用目标物体上的对应事件接口</div><div><span style="font-size: 14px; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 250, 165); color: rgb(0, 0, 0); font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;-evernote-highlight:true;">对事件脚本的查找是向上查找的，如C是B的子节点，B是A的子节点。射线检测的结果是C。那么会按C-&gt;B-&gt;A的顺序去查找可响应该事件的对象。</span></div><div><img src="Evernote_files/Image [68].png" type="image/png" data-filename="Image.png" width="513"/></div><div><br/></div><div><span style="font-size: 17pt;"><span style="font-size: 17pt; color: rgb(79, 79, 79); font-family: &quot;PingFang SC&quot;; font-weight: bold;">相关组件和类</span></span></div><h3 style="margin: 10px 0px; padding: 0px; font-size: 16px; letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255);"><span style="font-size: 16px; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; color: rgb(0, 0, 0); font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: bold; line-height: 1.5;">EventSystem</span></h3><ol><li><div>维护其GO上的所有InputModule(在Update中调用所有InputModule的updateModule),负责InputModule的切换(激活与失效); InputModule的tick在该类执行(当前输入系统只能存在一个);只会执行当前InputModule的Process</div></li><li><div>执行射线检测 RaycastAll</div></li><li><div>执行选中go SetSelectedGameObject;触发 ISelectHandler 和 IDeselectHandler(上文的按键导航效果)</div></li></ol><div><br/></div><h3 style="margin: 10px 0px; padding: 0px; font-size: 16px; letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255);"><span style="font-size: 16px; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; color: rgb(0, 0, 0); font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: bold; line-height: 1.5;">StandaloneInputModule</span></h3><div><span style="font-size: 16px; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; color: rgb(0, 0, 0); font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: bold; line-height: 1.5;">接收用户输入</span></div><div><span style="font-size: 12pt;"><span style="font-size: 12pt; font-family: &quot;PingFang SC&quot;; font-weight: bold;">封装了Input输入</span></span> ,<span style="font-size: 14px; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; color: rgb(0, 0, 0); font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">提供切换Input的能力</span></div><div><span style="font-size: 16px; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; color: rgb(0, 0, 0); font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: bold; line-height: 1.5;">StandaloneInputModule的Process流程: </span></div><ol><li><div>执行当前选中对象的UpdateSelect事件, 传入的事件数据是空白数据(BaseEvent)</div></li><li><div>执行触摸事件;</div></li><li><div>(前置条件 不存在触摸事件且存在鼠标) 执行鼠标事件 ProcessMouseEvent(),详情见下文</div></li><li><div>当ES开启了导航事件 处理导航移动和发送事件<img src="Evernote_files/Image [69].png" type="image/png" data-filename="Image.png"/></div></li><ul><li><div>导航移动和发送事件分别指的是Input的输入的水平垂直值和按钮事件 和 Submit/Cancel按钮事件<img src="Evernote_files/Image [70].png" type="image/png" data-filename="Image.png" width="526"/></div></li></ul></ol><div><span style="font-size: 11pt;">执行鼠标事件</span><span style="font-size: 11pt;">ProcessMouseEvent()</span><span style="font-size: 16px; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; color: rgb(0, 0, 0); font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: bold; line-height: 1.5;">流程: </span></div><div>pointInputModule 存储了鼠标三个按键(左右中)的数据pointEventData </div><ol><li><div><span style="font-size: 14px; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; color: rgb(51, 51, 51); font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">更新</span><span style="font-size: 11pt; color: rgb(51, 51, 51); font-family: &quot;PingFang SC&quot;;">pointEventData的pos和移动deltaΔ值 :</span><span style="font-size: 14px; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; color: rgb(51, 51, 51); font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">将鼠标位置和与上一帧差异更新到</span><span style="font-size: 11pt; color: rgb(51, 51, 51); font-family: &quot;PingFang SC&quot;;">pointEventData</span><span style="font-size: 14px; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; color: rgb(51, 51, 51); font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">中</span></div></li><li><div>射线获取第一个对象为事件对象 :  <span style="font-size: 12px; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(251, 229, 225); color: rgb(192, 52, 29); font-family: ui-monospace, SFMono-Regular, &quot;SF Mono&quot;, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">EventSytem.RaycastAll 获取规则下文展开</span></div></li><li><div>更新 左、右、中键的状态: 通过Input.GetBottonUp/dowm变更当前帧的状态<span style="font-size: 9pt; color: rgb(192, 52, 29); font-family: ui-monospace;"><img src="Evernote_files/Image [71].png" type="image/png" data-filename="Image.png" width="378"/></span></div></li><li><div>按顺序处理事件</div></li><ol><li><div><span style="font-size: 14px; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; color: rgb(51, 51, 51); font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">处理左键的</span><span style="font-size: 12px; display: inline-block; overflow-x: auto; vertical-align: middle; border-radius: 3px; background-color: rgb(251, 229, 225); letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; border: none !important; color: rgb(192, 52, 29); font-family: ui-monospace, SFMono-Regular, &quot;SF Mono&quot;, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; line-height: 1.8;">Press、Move、Drag</span><span style="font-size: 14px; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; color: rgb(51, 51, 51); font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">事件。</span></div></li><li><div><span style="font-size: 14px; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255); color: rgb(51, 51, 51); font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">处理右键和中键的</span><span style="font-size: 12px; display: inline-block; overflow-x: auto; vertical-align: middle; border-radius: 3px; background-color: rgb(251, 229, 225); letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; border: none !important; color: rgb(192, 52, 29); font-family: ui-monospace, SFMono-Regular, &quot;SF Mono&quot;, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; line-height: 1.8;">Press、Drag</span><span style="font-size: 14px; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; color: rgb(51, 51, 51); font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">事件。</span></div></li><li><div><span style="font-size: 14px; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; color: rgb(51, 51, 51); font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">处理滚轮事件。</span><span style="font-size: 11pt; color: rgb(51, 51, 51); font-family: &quot;PingFang SC&quot;;"><img src="Evernote_files/Image [72].png" type="image/png" data-filename="Image.png"/></span></div></li></ol></ol><h4 style="margin: 10px 0px; padding: 0px; font-size: 14px; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255);"><span style="font-size: 14px; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; color: rgb(51, 51, 51); font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: bold;">如何找到真正能响应事件的对象</span></h4><p style="margin: 10px auto; padding: 0px; text-indent: 0px; color: rgb(51, 51, 51); font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; font-size: 14px; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-align: start; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255);"></p><div><span style="font-size: 12px; display: inline-block; overflow-x: auto; vertical-align: middle; border-radius: 3px; background-color: rgb(251, 229, 225); border: none !important; color: rgb(192, 52, 29); font-family: ui-monospace, SFMono-Regular, &quot;SF Mono&quot;, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace, sans-serif; line-height: 1.8;">ExecuteEvents.GetEventHandler&lt;T&gt;</span>方法，它传入的是<span style="font-size: 12px; display: inline-block; overflow-x: auto; vertical-align: middle; border-radius: 3px; background-color: rgb(251, 229, 225); border: none !important; color: rgb(192, 52, 29); font-family: ui-monospace, SFMono-Regular, &quot;SF Mono&quot;, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace, sans-serif; line-height: 1.8;">Rayast</span>获得的<span style="font-size: 12px; display: inline-block; overflow-x: auto; vertical-align: middle; border-radius: 3px; background-color: rgb(251, 229, 225); border: none !important; color: rgb(192, 52, 29); font-family: ui-monospace, SFMono-Regular, &quot;SF Mono&quot;, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace, sans-serif; line-height: 1.8;">GameObject</span>，返回的是真正有实现了<span style="font-size: 12px; display: inline-block; overflow-x: auto; vertical-align: middle; border-radius: 3px; background-color: rgb(251, 229, 225); border: none !important; color: rgb(192, 52, 29); font-family: ui-monospace, SFMono-Regular, &quot;SF Mono&quot;, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace, sans-serif; line-height: 1.8;">T</span>接口的组件的<span style="font-size: 12px; display: inline-block; overflow-x: auto; vertical-align: middle; border-radius: 3px; background-color: rgb(251, 229, 225); border: none !important; color: rgb(192, 52, 29); font-family: ui-monospace, SFMono-Regular, &quot;SF Mono&quot;, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace, sans-serif; line-height: 1.8;">GameObject</span>。</div><div style="margin-top: 1em; margin-bottom: 1em;"><span style="-en-paragraph:true;">此方法从传入的</span><span style="font-size: 12px; display: inline-block; overflow-x: auto; vertical-align: middle; border-radius: 3px; background-color: rgb(251, 229, 225); border: none !important; color: rgb(192, 52, 29); font-family: ui-monospace, SFMono-Regular, &quot;SF Mono&quot;, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace, sans-serif; line-height: 1.8;-en-paragraph:true;">GameObject</span><span style="-en-paragraph:true;">向其</span><span style="font-size: 12px; display: inline-block; overflow-x: auto; vertical-align: middle; border-radius: 3px; background-color: rgb(251, 229, 225); border: none !important; color: rgb(192, 52, 29); font-family: ui-monospace, SFMono-Regular, &quot;SF Mono&quot;, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace, sans-serif; line-height: 1.8;-en-paragraph:true;">Transform</span><span style="-en-paragraph:true;">层级的根方向进行冒泡，直到找到一个有实现了</span><span style="font-size: 12px; display: inline-block; overflow-x: auto; vertical-align: middle; border-radius: 3px; background-color: rgb(251, 229, 225); border: none !important; color: rgb(192, 52, 29); font-family: ui-monospace, SFMono-Regular, &quot;SF Mono&quot;, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace, sans-serif; line-height: 1.8;-en-paragraph:true;">T</span><span style="-en-paragraph:true;">接口组件的对象。</span></div><div style="margin-top: 1em; margin-bottom: 1em;"><span style="font-size: 14px; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; color: rgb(51, 51, 51); font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: bold;">真正响应点击事件的对象 - IPointDownHander: 从</span><span style="font-size: 12px; display: inline-block; overflow-x: auto; vertical-align: middle; border-radius: 3px; background-color: rgb(251, 229, 225); border: none !important; color: rgb(192, 52, 29); font-family: ui-monospace, SFMono-Regular, &quot;SF Mono&quot;, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace, sans-serif; line-height: 1.8;">Rayast</span>获得的<span style="font-size: 12px; display: inline-block; overflow-x: auto; vertical-align: middle; border-radius: 3px; background-color: rgb(251, 229, 225); border: none !important; color: rgb(192, 52, 29); font-family: ui-monospace, SFMono-Regular, &quot;SF Mono&quot;, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace, sans-serif; line-height: 1.8;">GameObject</span>，返回的是有实现了<span style="font-size: 14px; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; color: rgb(51, 51, 51); font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: bold;">IPointDownHander</span>接口的组件的<span style="font-size: 12px; display: inline-block; overflow-x: auto; vertical-align: middle; border-radius: 3px; background-color: rgb(251, 229, 225); border: none !important; color: rgb(192, 52, 29); font-family: ui-monospace, SFMono-Regular, &quot;SF Mono&quot;, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace, sans-serif; line-height: 1.8;">GameObject,</span>更新PointEventData里的pointPress对象.  在释放鼠标后判断当前pointPress是否和射线选中go中获取到是同一个, 相同则执行Click事件<img src="Evernote_files/Image [73].png" type="image/png" data-filename="Image.png"/></div><div><br/></div><h3 style="margin: 10px 0px; padding: 0px; font-size: 16px; letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255);"><span style="font-size: 16px; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; color: rgb(0, 0, 0); font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: bold; line-height: 1.5;">Raycaster</span></h3><div><span style="font-size: 12pt;"><span style="font-size: 12pt; font-family: &quot;PingFang SC&quot;; font-weight: bold;">根据用户输入找到目标物体</span></span></div><div><font style="font-size: 10pt;"><span style="box-sizing: border-box; outline: 0px; overflow-wrap: break-word; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; font-size: 10pt; color: rgb(79, 79, 79); font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, SimHei, Arial, SimSun; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: bold; line-height: 32px;">如果监听3D物体-给摄像机加Physics Raycaster 或</span><span style="box-sizing: border-box; outline: 0px; overflow-wrap: break-word; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; font-size: 10pt; color: rgb(79, 79, 79); font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, SimHei, Arial, SimSun; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: bold; line-height: 32px;">Physics 2D Raycaster</span></font></div><div><img src="Evernote_files/Image [74].png" type="image/png" data-filename="Image.png" width="553"/></div><div><span style="font-size: 10pt; outline: 0px; --el-button-active-border-color: #6d5ffd; overflow-wrap: break-word; color: rgb(79, 79, 79); font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, SimHei, Arial, SimSun; font-weight: bold; line-height: 32px;">如果</span><span style="font-size: 10pt; outline: 0px; --el-button-active-border-color: #6d5ffd; overflow-wrap: break-word; color: rgb(79, 79, 79); font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, SimHei, Arial, SimSun; font-weight: bold; line-height: 32px;">监</span><span style="font-size: 10pt; outline: 0px; --el-button-active-border-color: #6d5ffd; overflow-wrap: break-word; color: rgb(79, 79, 79); font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, SimHei, Arial, SimSun; font-weight: bold; line-height: 32px;">听UI，在Canvas对象下挂载GraphicRaycaster</span></div><div><img src="Evernote_files/Image [75].png" type="image/png" data-filename="Image.png" width="552"/></div><div>GraphicRaycaster是如何工作的: </div><ul><li><div>Raycaster在<span style="font-size: 14px; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; color: rgb(0, 0, 0); font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">Onenable，OnDisable时会把自己加入或移除在</span><span style="font-size: 11pt; font-family: &quot;PingFang SC&quot;;">RaycasterManager中;当Es调用RaycastAll时所有激活的</span><span style="font-size: 11pt; font-family: &quot;PingFang SC&quot;;">Raycaster都会执行</span><span style="font-size: 11pt; font-family: &quot;PingFang SC&quot;;">Raycast操作</span></div></li><li><div>Graphic <span style="font-size: 14px; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; color: rgb(0, 0, 0); font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">在Onenable，OnDisable，</span><span style="font-size: 14px; color: rgb(0, 0, 0); font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; text-decoration: underline;">OnBeforeTransformParentChanged，OnTransformParentChanged，OnCanvasHierarchyChanged(UIBehaviour的下属方法)</span><span style="font-size: 14px; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; color: rgb(0, 0, 0); font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">这几个时间点把自己加入或移除一个以canvas为键值的graphic集合的字典中(</span><span style="background-color: rgb(255, 250, 165);-evernote-highlight:true;">GraphicRegistry</span><span style="font-size: 14px; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; color: rgb(0, 0, 0); font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">)。</span></div></li><li><div><span style="font-size: 11pt; font-family: &quot;PingFang SC&quot;;">具体调用过程:</span></div></li><ul><li><div><span style="font-size: 11pt; font-family: &quot;PingFang SC&quot;;">获取当前Canvas下所有的Graphic</span></div></li><li><div>处理多分辨率下射线目标位置,获取相应的正确缩放后的位置</div></li><li><div><span style="font-size: 11pt; font-family: &quot;PingFang SC&quot;;">当Canvas的渲染模式</span><span style="font-size: 11pt; font-family: &quot;PingFang SC&quot;; font-weight: bold;">不为</span><span style="font-weight: bold;">ScreenSpaceOverlay(屏幕覆盖)</span>时,获取遮挡物体离射线的距离,用于剔除比遮挡物体距离更大的<span style="font-size: 11pt; font-family: &quot;PingFang SC&quot;;">Graphic,</span> <span style="font-size: 12px; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(251, 229, 225); display: inline-block; overflow-x: auto; vertical-align: middle; border-radius: 3px; border: none !important; color: rgb(192, 52, 29); font-family: ui-monospace, SFMono-Regular, &quot;SF Mono&quot;, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: bold; line-height: 1.8;">BlockingObjects:</span><span style="font-size: 9pt;"><span style="font-size: 9pt; color: rgb(192, 52, 29); font-family: ui-monospace; font-weight: bold;">这个属性决定了哪些物体会使射线停止，而不再继续穿透</span></span> ; 遮挡检测的射线用的是 <span style="font-size: 12px; display: inline-block; overflow-x: auto; vertical-align: middle; border-radius: 3px; background-color: rgb(251, 229, 225); letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; border: none !important; color: rgb(192, 52, 29); font-family: ui-monospace, SFMono-Regular, &quot;SF Mono&quot;, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; line-height: 1.8;">Physics</span><span style="font-size: 14px; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255); color: rgb(51, 51, 51); font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">类的</span><span style="font-size: 12px; display: inline-block; overflow-x: auto; vertical-align: middle; border-radius: 3px; background-color: rgb(251, 229, 225); letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; border: none !important; color: rgb(192, 52, 29); font-family: ui-monospace, SFMono-Regular, &quot;SF Mono&quot;, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; line-height: 1.8;">Raycast</span><span style="font-size: 14px; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; color: rgb(51, 51, 51); font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">系列方法完成的</span></div></li><li><div>处理所有Graphic,<span style="text-decoration: underline;">先排除不需要检测的</span>,然后 通过<span style="text-decoration: underline;">RectTransformUtility.RectangleContainsScreenPoint</span>判断射线击中点是否在Graphic的RectTransform中，再通过Graphic自身的Raycast函数进行进一步的检测（检测CanvasGroup，Active状态等）;检测结果依据<span style="font-size: 11pt; font-family: &quot;PingFang SC&quot;;">Graphic的Depth从大到小排序</span></div></li><ul><li><div>不需要检测的对象包括:</div></li><ul><li><div><span style="font-size: 11pt; font-family: &quot;PingFang SC&quot;;">Graphic的</span>raycastTarget属性为false时</div></li><li><div>CanvasRander的cull属性为为true时<img src="Evernote_files/Image [76].png" type="image/png" data-filename="Image.png"/></div></li><li><div><span style="font-size: 11pt; font-family: &quot;PingFang SC&quot;;">Graphic的Depth =-1</span></div></li></ul><li><div><span style="box-sizing: border-box; border-width: 0px; border-style: solid; border-color: rgb(229, 231, 235); --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgb(59 130 246 / 0.5); --tw-ring-offset-shadow: 0 0 #0000; --tw-ring-shadow: 0 0 #0000; --tw-shadow: 0 0 #0000; --tw-shadow-colored: 0 0 #0000; font-size: 11.9px; background-color: var(--color-neutral-muted); border-radius: 6px; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; color: rgb(36, 41, 47); font-family: ui-monospace, SFMono-Regular, &quot;SF Mono&quot;, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-variant-caps: normal; font-variant-ligatures: normal;">RectTransformUtility.RectangleContainsScreenPoint : </span><span style="font-size: 14px; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: pre-wrap; background-color: rgb(244, 246, 248); color: rgb(36, 41, 47); font-family: -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, &quot;Noto Sans&quot;, Helvetica, Arial, sans-serif, &quot;Apple Color Emoji&quot;, &quot;Segoe UI Emoji&quot;; font-variant-caps: normal; font-variant-ligatures: normal;">用于检查一个屏幕空间坐标点(上文中的射线点)是否在某个</span> <span style="box-sizing: border-box; border-width: 0px; border-style: solid; border-color: rgb(229, 231, 235); --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgb(59 130 246 / 0.5); --tw-ring-offset-shadow: 0 0 #0000; --tw-ring-shadow: 0 0 #0000; --tw-shadow: 0 0 #0000; --tw-shadow-colored: 0 0 #0000; font-size: 11.9px; background-color: var(--color-neutral-muted); border-radius: 6px; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; color: rgb(36, 41, 47); font-family: ui-monospace, SFMono-Regular, &quot;SF Mono&quot;, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-variant-caps: normal; font-variant-ligatures: normal;">RectTransform</span> <span style="font-size: 14px; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: pre-wrap; background-color: rgb(244, 246, 248); color: rgb(36, 41, 47); font-family: -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, &quot;Noto Sans&quot;, Helvetica, Arial, sans-serif, &quot;Apple Color Emoji&quot;, &quot;Segoe UI Emoji&quot;; font-variant-caps: normal; font-variant-ligatures: normal;">的矩形范围内</span></div></li><li><div><span style="font-size: 11pt; font-family: &quot;PingFang SC&quot;;">Graphic的射线检查接口: </span><span style="font-size: 11pt; font-family: &quot;PingFang SC&quot;;">ICanvasRaycastFilter ; 结果为false说明不响应射线; 会向父节点冒泡检查</span></div></li></ul><li><div><span style="font-size: 11pt; color: rgb(36, 41, 47);">剔除距离比遮挡物体距离大的</span><span style="font-size: 11pt; font-family: &quot;PingFang SC&quot;;">Graphic;当Canvas的渲染模式为</span>ScreenSpaceOverlay(屏幕覆盖)时,所有<span style="font-size: 11pt; font-family: &quot;PingFang SC&quot;;">Graphic对于射线的距离都会被设置为0,加入结果列表</span></div></li></ul><li><div><span style="font-size: 11pt; font-family: &quot;PingFang SC&quot;;">射线检测结果排序</span></div></li><ul><li><div><span style="font-size: 11pt; font-family: &quot;PingFang SC&quot;;">所有的</span> <span style="font-size: 14px; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; color: rgb(0, 0, 0); font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">aycaster都进行一次射线检测，获取当前射线击中的所有物体，统一进行排序，选排序后的第一个对象作为射线检测的结果。</span></div></li><li><div><span style="font-size: 11pt; font-family: &quot;PingFang SC&quot;;">规则 : </span></div></li><ul><li><div><span style="font-size: 14px; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; color: rgb(0, 0, 0); font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">不同Racaster下：</span></div></li><ul><li><div><span style="font-size: 14px; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; color: rgb(0, 0, 0); font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">camera.depth</span></div></li><li><div><span style="font-size: 14px; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; color: rgb(0, 0, 0); font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">Raycaster.sortOrderPriority 针对ScreenSpaceOverlay</span></div></li><li><div><span style="font-size: 14px; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; color: rgb(0, 0, 0); font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">Raycaster.renderOrderPriority 针对ScreenSpaceOverlay</span></div></li></ul><li><div><span style="font-size: 14px; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; color: rgb(0, 0, 0); font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">相同Racaster下：</span></div></li><ul><li><div><span style="font-size: 14px; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; color: rgb(0, 0, 0); font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">sortingLayer</span></div></li><li><div><span style="font-size: 14px; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; color: rgb(0, 0, 0); font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">sortingOrder</span></div></li><li><div><span style="font-size: 14px; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255); color: rgb(0, 0, 0); font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">depth</span></div></li><li><div><span style="font-size: 14px; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; color: rgb(0, 0, 0); font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">distance</span></div></li><li><div><span style="font-size: 14px; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; color: rgb(0, 0, 0); font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">index</span></div></li></ul><li><div>对比数据来源<img src="Evernote_files/Image [77].png" type="image/png" data-filename="Image.png"/></div></li></ul></ul></ul><div><br/></div><hr/><div><a href="https://www.cnblogs.com/axun1992/p/16004846.html#raycastall%E6%96%B9%E6%B3%95" style="font-size: 16pt; font-weight: bold;">https://www.cnblogs.com/axun1992/p/16004846.html#raycastall%E6%96%B9%E6%B3%95</a></div><div><a href="https://www.cnblogs.com/blueberryzzz/p/12216045.html" style="font-size: 16pt;">https://www.cnblogs.com/blueberryzzz/p/12216045.html</a></div><div><br/></div><div><br/></div></div></span>
</div>
<hr>
<a name="670"/>

<div>
<span><div><div><div>日志系统</div><div>文件存放位置: C:\Users\&lt;YourUserName&gt;\AppData\Local\Unity\Editor\Editor.log</div><div>系统自带日志文件存在的问题: </div><ol><li><div>日志输出没有时间和帧数</div></li><li><div>输出等级区分度不大</div></li><li><div>长时间不清理,存储空间会占用很大</div></li></ol><div><br/></div></div><div>Log小技巧:</div><ol><li><div>打印任意类型参数,需要重写ToString方法</div></li><li><div><span style="text-decoration: underline;">.log的第二个参数可以定位到资源位置;如果设置的物体还没有实例化会直接定位到project视图中的资源</span></div></li></ol><div>存储和上传</div><div>Application.logMessageReceived 事件可以监听日志</div><div>Application.persistentDataPath 用于存放日志文件</div><div>上传流程</div><div><img src="Evernote_files/Image [78].png" type="image/png" data-filename="Image.png"/></div><div>日志溯源问题: 当把UnityEngine.Debug.Log 封装附加额外功能之后(文本颜色,打印时间,打印游戏帧,宏等)在编译器上双击日志文本跳转到的地方不是调用代码的地址,因为直接调用的地方是封装api</div><ol><li><div>将log编译成另外的dll,放在Plugins目录下</div></li><li><div>OnOpenAssetAttribute  是 Unity 提供的一个特性，用于自定义在 编辑器中打开资产（Asset）时的行为。通过这个特性，指定一个方法，该方法会在双击某个资产时被调用，从而实现特定的操作，比如打开自定义编辑器窗口、处理资产数据等。利用这个特性,结合正则表达式获取到实际的调用位置,再使用跳转目标代码的特定行api就可以实现</div></li></ol><div><span style="font-weight: bold; color: rgb(33, 33, 33); font-family: Inter, &quot;Noto Sans SC&quot;, &quot;Noto Sans JP&quot;, &quot;Noto Sans KR&quot;, Roboto, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Oxygen, Ubuntu, Cantarell, &quot;Fira Sans&quot;, &quot;Droid Sans&quot;, &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; font-size: 16px; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255);">SRDebugger</span><span style="color: rgb(33, 33, 33); font-family: Inter, &quot;Noto Sans SC&quot;, &quot;Noto Sans JP&quot;, &quot;Noto Sans KR&quot;, Roboto, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Oxygen, Ubuntu, Cantarell, &quot;Fira Sans&quot;, &quot;Droid Sans&quot;, &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; font-size: 16px; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal;"> 插件</span></div></div></span>
</div>
<hr>
<a name="687"/>

<div>
<span><div><div><span style="font-size: 16pt; font-weight: bold;">UGUI相关</span></div><h1 style="margin: 0px 0px 1.3rem; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal;"><span style="letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal;"><span style="color: var(--juejin-font-1); font-family: -apple-system, system-ui, &quot;Segoe UI&quot;, Roboto, Ubuntu, Cantarell, &quot;Noto Sans&quot;, sans-serif, BlinkMacSystemFont, &quot;Helvetica Neue&quot;, &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, Arial; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: bold; line-height: 1.31; font-size: 10pt;">UGUI—深入理解Canvas Scaler屏幕自适应:</span></span></h1><div><span style="font-size: 16pt;"><a href="https://juejin.cn/post/6990618605771718664" style="font-size: 16pt; font-weight: bold;">https://juejin.cn/post/6990618605771718664</a></span></div><div><br/></div><div>框架: <span style="color: rgb(24, 25, 28); font-family: -apple-system, BlinkMacSystemFont, &quot;Helvetica Neue&quot;, Helvetica, Arial, &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, sans-serif; font-size: 16px; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: pre-line; background-color: rgb(255, 255, 255);"><a href="https://gitee.com/ChinaHeNan5205/simple-uimanager.git">https://gitee.com/ChinaHeNan5205/simple-uimanager.git</a></span></div><div><span style="font-size: 16pt;"><br/></span></div><div>UGUI优化</div><ol><li><div>不需要接收输入事件的元素禁用Raycast Target;可以节省cpu处理时间</div></li><li><div>避免元素堆叠,堆叠元素会影响UGUI合批,还会造成 <span style="font-size: medium; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; color: rgb(25, 27, 31); font-family: -apple-system, BlinkMacSystemFont, &quot;Helvetica Neue&quot;, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Source Han Sans SC&quot;, &quot;Noto Sans CJK SC&quot;, &quot;WenQuanYi Micro Hei&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">OverDraw</span></div></li><li><div><span style="color: rgb(25, 27, 31);">同一界面的ui尽量使用相同的材质球,图片打成图集</span></div></li><li><div>动静分离Canvas;Canvas下元素属性改变会进行Canvas的rebuild重新计算生成网格</div></li><li><div>canvas层级尽量减少,减少重新计算深度的时间</div></li><li><div>canvas优化:同个概念层可以分为需要射线检测和不需要射线检测的canvas</div></li><ol><li><div><span style="font-weight: bold;"><img src="Evernote_files/Image [79].png" type="image/png" data-filename="Image.png"/></span></div></li></ol><li><div>简单的单个遮罩使用rectMask2d</div></li></ol><div>UGUI：调整Unity中UI和特效的层级关系</div><div>原文链接：<a href="https://blog.csdn.net/qq_33461689/article/details/106135399">https://blog.csdn.net/qq_33461689/article/details/106135399</a></div><div><span style="font-size: 14pt; font-weight: bold;">关于精灵的像素和世界单位的转换</span></div><div><span style="box-sizing: border-box; border-width: 0px; border-style: solid; border-color: rgb(229, 231, 235); --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgb(59 130 246 / 0.5); --tw-ring-offset-shadow: 0 0 #0000; --tw-ring-shadow: 0 0 #0000; --tw-shadow: 0 0 #0000; --tw-shadow-colored: 0 0 #0000; font-weight: bold;">Pixels Per Unit = 100</span> 意味着<span style="background-color: rgb(255, 250, 165);-evernote-highlight:true;">每 100 像素的图像将在 Unity 中表示为 1 个单位</span>。换句话说，如果你的精灵图像的宽度是 100 像素，那么在游戏世界中，它的宽度将是 1 个单位。</div><div><img src="Evernote_files/Image [80].png" type="image/png" data-filename="Image.png" width="427"/></div><div><br/></div><div><br/></div><div><span style="letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="font-size: 14pt; color: rgb(0, 0, 0); font-family: 微软雅黑; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: bold;">ICanvasRaycastFilter接口</span></span></div><div>ICanvasRaycastFilter接口 :  允许开发者决定是否允许某个 UI 元素（通常是 UI 组件）响应射线检测。</div><ul><ul><li><div>如果返回 true，则表示该 UI 元素会响应射线检测，允许点击或触摸等输入事件。</div></li><li><div>如果返回 false，则表示该 UI 元素会忽略射线输入，即用户的点击或触摸不会触发该元素的交互。</div></li></ul></ul><div>可以用于实现不规则图片点击,判断点击位置的像素的alpha值; 但是需要打开图片资源的<span style="font-size: medium; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; color: rgb(25, 27, 31); font-family: -apple-system, BlinkMacSystemFont, &quot;Helvetica Neue&quot;, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Source Han Sans SC&quot;, &quot;Noto Sans CJK SC&quot;, &quot;WenQuanYi Micro Hei&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">Read/Write Enabled选项</span> <span style="font-size: medium; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; color: rgb(25, 27, 31); font-family: -apple-system, BlinkMacSystemFont, &quot;Helvetica Neue&quot;, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Source Han Sans SC&quot;, &quot;Noto Sans CJK SC&quot;, &quot;WenQuanYi Micro Hei&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">（调用Texture.GetPixel和Texture.SetPixel APIs）</span><span style="font-size: medium; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; color: rgb(25, 27, 31); font-family: -apple-system, BlinkMacSystemFont, &quot;Helvetica Neue&quot;, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Source Han Sans SC&quot;, &quot;Noto Sans CJK SC&quot;, &quot;WenQuanYi Micro Hei&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">:</span></div><div><span style="font-size: medium; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; color: rgb(25, 27, 31); font-family: -apple-system, BlinkMacSystemFont, &quot;Helvetica Neue&quot;, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Source Han Sans SC&quot;, &quot;Noto Sans CJK SC&quot;, &quot;WenQuanYi Micro Hei&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">打开read/write enabled标签会造成贴图会在内存中被保留两份。一份在GPU显存中，一份在CPU可寻址内存（CPU-addressable memory）中。</span> (<span style="font-size: medium; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; color: rgb(25, 27, 31); font-family: -apple-system, BlinkMacSystemFont, &quot;Helvetica Neue&quot;, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Source Han Sans SC&quot;, &quot;Noto Sans CJK SC&quot;, &quot;WenQuanYi Micro Hei&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">这是因为，CPU读取GPU显存是非常慢的。CPU读取显存中的一张贴图到一个临时的缓存中也不怎么现实）</span></div><div style="box-sizing: border-box; padding: 8px; font-family: Monaco, Menlo, Consolas, &quot;Courier New&quot;, monospace; font-size: 12px; color: rgb(51, 51, 51); border-radius: 4px; background-color: rgb(251, 250, 248); border: 1px solid rgba(0, 0, 0, 0.15);-en-codeblock:true;"><div>public class IrregularRaycast : MonoBehaviour, ICanvasRaycastFilter</div><div>{</div><div>    public Image targetImage;  // 要检测点击的图像</div><div>    private Texture2D texture; // 用于存储图片的纹理</div><div><br/></div><div><br/></div><div>    void Start()</div><div>    {</div><div>        // 获取图像的纹理</div><div>        texture = targetImage.sprite.texture;</div><div>    }</div><div><br/></div><div><br/></div><div>    // 实现 ICanvasRaycastFilter 接口</div><div>    public bool IsRaycastLocationValid(Vector2 sp, Camera eventCamera)</div><div>    {</div><div>        // 将屏幕坐标转换为图片的局部坐标</div><div>        RectTransform rectTransform = targetImage.rectTransform;</div><div>        Vector2 localPos;</div><div>        RectTransformUtility.ScreenPointToLocalPointInRectangle(rectTransform, sp, eventCamera, out localPos);</div><div>        </div><div>        // 获取图片的局部坐标对应的纹理像素</div><div>        Vector2 textureCoord = new Vector2(</div><div>            (localPos.x - rectTransform.rect.xMin) / rectTransform.rect.width,</div><div>            (localPos.y - rectTransform.rect.yMin) / rectTransform.rect.height</div><div>        );</div><div>        </div><div>        // 将纹理坐标转换为实际的纹理像素坐标</div><div>        int x = Mathf.FloorToInt(textureCoord.x * texture.width);</div><div>        int y = Mathf.FloorToInt(textureCoord.y * texture.height);</div><div>        </div><div>        // 获取像素的 Alpha 值</div><div>        Color pixelColor = texture.GetPixel(x, y);</div><div>        </div><div>        // 如果 Alpha 值大于 0，表示点击在图片的有效区域</div><div>        return pixelColor.a &gt; 0;</div><div>    }</div><div>}</div></div><div><span style="font-size: 11pt;"><br/></span></div><div>ScrollRect相关:</div><ol><li><div>scrollRect.horizontalNormalizedPosition的值计算方式是 <span style="font-weight: bold;">(</span><span style="font-size: unset; color: unset; font-family: unset; font-weight: bold;">视图最小</span><span style="font-size: unset; color: unset; font-family: unset; font-weight: bold;">x</span><span style="font-size: unset; color: unset; font-family: unset; font-weight: bold;">位置</span> <span style="font-size: unset; color: unset; font-family: unset; font-weight: bold;">-</span> <span style="font-size: unset; color: unset; font-family: unset; font-weight: bold;">内容最小</span><span style="font-size: unset; color: unset; font-family: unset; font-weight: bold;">x</span><span style="font-size: unset; color: unset; font-family: unset; font-weight: bold;">位置</span><span style="font-size: unset; color: unset; font-family: unset; font-weight: bold;">) / (</span><span style="font-size: unset; color: unset; font-family: unset; font-weight: bold;">内容宽度</span> <span style="font-size: unset; color: unset; font-family: unset; font-weight: bold;">-</span> <span style="font-size: unset; color: unset; font-family: unset; font-weight: bold;">视图宽度</span><span style="font-size: unset; color: unset; font-family: unset; font-weight: bold;">)</span><span style="font-size: unset; color: unset; font-family: unset;">当</span><span style="font-size: unset; color: unset; font-family: unset;">Content</span><span style="font-size: unset; color: unset; font-family: unset;">的锚点 不是</span> <span style="font-size: unset; color: unset; font-family: unset;">min(0.5,0.5) max(0.5,0.5)</span> <span style="font-size: unset; color: unset; font-family: unset;">时，会导致计算的水平位置不准确</span><span style="font-size: unset; color: unset; font-family: unset;">,</span><span style="font-size: unset; color: unset; font-family: unset;">出现负值</span><span style="font-size: unset; color: unset; font-family: unset;">(</span><span style="font-size: unset; color: unset; font-family: unset;">比如</span><span style="font-size: unset; color: unset; font-family: unset;">anchors 0,1,1,1)</span></div></li></ol><div><img src="Evernote_files/Image [81].png" type="image/png" data-filename="Image.png"/></div><div><br/></div></div><div><br/></div></span>
</div>
<hr>
<a name="705"/>

<div>
<span><div><span style="font-size: 14pt; font-weight: bold;">协变和逆变 covariant &amp; contravariant</span></div><div><span style="font-size: 14px; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal;">应用于委托和接口, in 表示逆变</span><span style="font-size: 14px; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; font-weight: bold;">仅作为入参时可用 </span> <span style="font-size: 14px; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal;">out 表示协变<b>仅在读取时可用 </b></span></div><div><span style="font-size: 15px; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; color: rgb(51, 51, 51); font-family: &quot;Microsoft YaHei&quot;; font-variant-caps: normal; font-variant-ligatures: normal;">协变</span><span style="font-size: 15px; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; color: rgb(51, 51, 51); font-family: &quot;Microsoft YaHei&quot;; font-variant-caps: normal; font-variant-ligatures: normal;">指能够使用比原始指定的派生类型的派生程度更大（更具体的）的类型，</span></div><div><span style="font-size: 15px; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; color: rgb(51, 51, 51); font-family: &quot;Microsoft YaHei&quot;; font-variant-caps: normal; font-variant-ligatures: normal;">逆变</span><span style="font-size: 15px; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; color: rgb(51, 51, 51); font-family: &quot;Microsoft YaHei&quot;; font-variant-caps: normal; font-variant-ligatures: normal;">指能够使用比原始指定的派生类型的派生程度更小（不太具体的）的类型。</span><a href="https://docs.microsoft.com/zh-cn/dotnet/standard/generics/covariance-and-contravariance" style="font-size: 15px; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; border-bottom: 1px dotted rgb(51, 51, 51); color: rgb(0, 0, 255); font-family: &quot;Microsoft YaHei&quot;; font-variant-caps: normal; font-variant-ligatures: normal;">[MSDN]</a> </div><div><span style="font-size: 14px; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; color: rgb(51, 51, 51); font-family: verdana, Arial, Helvetica, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; text-decoration: underline;">派生程度小可以理解为基类，派生程度大可以理解为子类或派生类</span></div><div><span style="font-size: 10pt;">概念: 假定X是Y的派生类, I&lt;X&gt; 的实例都能转换为I&lt;Y&gt;类型, 那么说I&lt;&gt; 是协变的</span></div><div><img src="Evernote_files/Image [82].png" type="image/png" data-filename="Image.png"/></div><div><br/></div></span>
</div>
<hr>
<a name="718"/>

<div>
<span><div><h1 style="box-sizing: border-box; outline: 0px; margin: 0px; padding: 0px; font-size: 28px; overflow-wrap: break-word; word-break: break-all; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255);"><span style="box-sizing: border-box; outline: 0px; font-size: 28px; overflow-wrap: break-word; word-break: break-all; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; color: rgb(34, 34, 38); font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, SimHei, Arial, SimSun; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: bold;">Unity中影响渲染顺序的因素总结</span></h1><div><span style="font-size: 16px; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; color: rgb(64, 64, 64); font-family: -apple-system, BlinkMacSystemFont, &quot;Apple Color Emoji&quot;, &quot;Segoe UI Emoji&quot;, &quot;Segoe UI Symbol&quot;, &quot;Segoe UI&quot;, &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">决定Unity渲染关系的层级顺序是：</span></div><div><span style="font-size: 16px; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; color: rgb(64, 64, 64); font-family: -apple-system, BlinkMacSystemFont, &quot;Apple Color Emoji&quot;, &quot;Segoe UI Emoji&quot;, &quot;Segoe UI Symbol&quot;, &quot;Segoe UI&quot;, &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">Camera</span></div><ul><li><div>Camera Depth : 深度置越大渲染时机越靠后,也就是说，深度大的摄像机的内容会直接覆盖在深度小的摄像机的内容上</div></li><li><div><span style="font-size: 16px; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; color: rgb(64, 64, 64); font-family: -apple-system, BlinkMacSystemFont, &quot;Apple Color Emoji&quot;, &quot;Segoe UI Emoji&quot;, &quot;Segoe UI Symbol&quot;, &quot;Segoe UI&quot;, &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">RenderQueue</span><span style="font-size: 16px; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; color: rgb(64, 64, 64); font-family: -apple-system, BlinkMacSystemFont, &quot;Apple Color Emoji&quot;, &quot;Segoe UI Emoji&quot;, &quot;Segoe UI Symbol&quot;, &quot;Segoe UI&quot;, &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;"> = 2500是透明与不透明物体的分界线,同一个相机下,小于2500(即不透明物体)先于2500之后的物体绘制</span></div></li></ul><div><span style="font-size: 16px; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; color: rgb(64, 64, 64); font-family: -apple-system, BlinkMacSystemFont, &quot;Apple Color Emoji&quot;, &quot;Segoe UI Emoji&quot;, &quot;Segoe UI Symbol&quot;, &quot;Segoe UI&quot;, &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">sorting layer</span></div><ul><li><div><span style="font-size: 18px; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; color: rgb(85, 85, 85); font-family: Lato, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">Renderer 中的属性,越低越早绘制</span></div></li></ul><div><span style="font-size: 12pt; color: rgb(64, 64, 64);">order in layer</span></div><ul><li><div><span style="font-size: 18px; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; color: rgb(85, 85, 85); font-family: Lato, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">Renderer 中的属性,相同的</span><span style="font-size: 16px; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; color: rgb(64, 64, 64); font-family: -apple-system, BlinkMacSystemFont, &quot;Apple Color Emoji&quot;, &quot;Segoe UI Emoji&quot;, &quot;Segoe UI Symbol&quot;, &quot;Segoe UI&quot;, &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">sorting layer下,数值越大,越在上方显示</span></div></li></ul><div><span style="font-size: 16px; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; color: rgb(64, 64, 64); font-family: -apple-system, BlinkMacSystemFont, &quot;Apple Color Emoji&quot;, &quot;Segoe UI Emoji&quot;, &quot;Segoe UI Symbol&quot;, &quot;Segoe UI&quot;, &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">RenderQueue</span><span style="font-size: 16px; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; color: rgb(64, 64, 64); font-family: -apple-system, BlinkMacSystemFont, &quot;Apple Color Emoji&quot;, &quot;Segoe UI Emoji&quot;, &quot;Segoe UI Symbol&quot;, &quot;Segoe UI&quot;, &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;"> </span></div><ul><li><div><span style="font-size: 18px; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; color: rgb(85, 85, 85); font-family: Lato, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">Shader中对Tags设置的“Queue”</span></div></li></ul><div><span style="font-size: 12pt; color: rgb(64, 64, 64);"><img src="Evernote_files/Image [83].png" type="image/png" data-filename="Image.png"/></span><span style="font-size: 12pt; color: rgb(64, 64, 64);"><img src="Evernote_files/Image [84].png" type="image/png" data-filename="Image.png"/></span><span style="font-size: 12pt; color: rgb(64, 64, 64);"><img src="Evernote_files/Image [85].png" type="image/png" data-filename="Image.png"/></span><span style="font-size: 12pt; color: rgb(64, 64, 64);"><img src="Evernote_files/Image [86].png" type="image/png" data-filename="Image.png" width="719"/></span></div><div><span style="font-size: 12pt; color: rgb(64, 64, 64);">1.Camera Depth: 越小越优先</span></div><div><span style="font-size: 12pt; color: rgb(64, 64, 64);">2.RenderQueue 2500以下</span></div><div><span style="font-size: 12pt; color: rgb(64, 64, 64);">    1. Sorting Layer/Order in Layer</span></div><div><span style="font-size: 12pt; color: rgb(64, 64, 64);">           1. 按照Sorting Layer/Order in Layer 设置的值，越小越优先</span></div><div><span style="font-size: 12pt; color: rgb(64, 64, 64);">           2. 无此属性，等同于 Sorting Layer=default ,Order in Layer=0 参与排序</span></div><div><span style="font-size: 12pt; color: rgb(64, 64, 64);">     2.RenderQueue 越小越优先</span></div><div><span style="font-size: 12pt; color: rgb(64, 64, 64);">     3.RenderQueue 相等，由近到远排序优先</span></div><div><span style="font-size: 12pt; color: rgb(64, 64, 64);">3.<span style="background-color: rgb(255, 250, 165); color: rgb(64, 64, 64); font-size: 12pt;-evernote-highlight:true;">RenderQueue 2500以上</span></span></div><div><span style="font-size: 12pt; color: rgb(64, 64, 64);">     1. Sorting Layer/Order in Layer</span></div><div><span style="font-size: 12pt; color: rgb(64, 64, 64);">           1. 按照Sorting Layer/Order in Layer 设置的值，越小越优先</span></div><div><span style="font-size: 12pt; color: rgb(64, 64, 64);">           2. 无此属性，等同于 Sorting Layer=default ,Order in Layer=0 参与排序</span></div><div><span style="font-size: 12pt; color: rgb(64, 64, 64);">     2.RenderQueue 越小越优先</span></div><div><span style="font-size: 12pt; color: rgb(64, 64, 64);">     3.RenderQueue 相等，</span><span style="font-size: 12pt; background-color: rgb(255, 250, 165); color: rgb(64, 64, 64);-evernote-highlight:true;">由远到近排序优先,半透明物体渲染顺序是由远到近的顺序</span></div></div><div><br/></div></span>
</div>
<hr>
<a name="724"/>

<div>
<span><div><div>Unity Shader 入门笔记</div><ol><li><div>shader 语义; 重要语义 <span style="font-size: 15px; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(253, 253, 254); color: rgb(5, 7, 59); font-family: -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, Ubuntu, &quot;Helvetica Neue&quot;, Helvetica, Arial, &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei UI&quot;, &quot;Microsoft YaHei&quot;, &quot;Source Han Sans CN&quot;, sans-serif, &quot;Apple Color Emoji&quot;, &quot;Segoe UI Emoji&quot;; font-variant-caps: normal; font-variant-ligatures: normal;">PO</span><span style="font-size: 15px; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(253, 253, 254); color: rgb(5, 7, 59); font-family: -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, Ubuntu, &quot;Helvetica Neue&quot;, Helvetica, Arial, &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei UI&quot;, &quot;Microsoft YaHei&quot;, &quot;Source Han Sans CN&quot;, sans-serif, &quot;Apple Color Emoji&quot;, &quot;Segoe UI Emoji&quot;; font-variant-caps: normal; font-variant-ligatures: normal;">S</span><span style="font-size: 15px; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(253, 253, 254); color: rgb(5, 7, 59); font-family: -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, Ubuntu, &quot;Helvetica Neue&quot;, Helvetica, Arial, &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei UI&quot;, &quot;Microsoft YaHei&quot;, &quot;Source Han Sans CN&quot;, sans-serif, &quot;Apple Color Emoji&quot;, &quot;Segoe UI Emoji&quot;; font-variant-caps: normal; font-variant-ligatures: normal;">ITION,</span> <span style="font-size: 15px; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(253, 253, 254); color: rgb(5, 7, 59); font-family: -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, Ubuntu, &quot;Helvetica Neue&quot;, Helvetica, Arial, &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei UI&quot;, &quot;Microsoft YaHei&quot;, &quot;Source Han Sans CN&quot;, sans-serif, &quot;Apple Color Emoji&quot;, &quot;Segoe UI Emoji&quot;; font-variant-caps: normal; font-variant-ligatures: normal;">SV_PO</span><span style="font-size: 15px; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(253, 253, 254); color: rgb(5, 7, 59); font-family: -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, Ubuntu, &quot;Helvetica Neue&quot;, Helvetica, Arial, &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei UI&quot;, &quot;Microsoft YaHei&quot;, &quot;Source Han Sans CN&quot;, sans-serif, &quot;Apple Color Emoji&quot;, &quot;Segoe UI Emoji&quot;; font-variant-caps: normal; font-variant-ligatures: normal;">S</span><span style="font-size: 15px; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(253, 253, 254); color: rgb(5, 7, 59); font-family: -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, Ubuntu, &quot;Helvetica Neue&quot;, Helvetica, Arial, &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei UI&quot;, &quot;Microsoft YaHei&quot;, &quot;Source Han Sans CN&quot;, sans-serif, &quot;Apple Color Emoji&quot;, &quot;Segoe UI Emoji&quot;; font-variant-caps: normal; font-variant-ligatures: normal;">ITION,</span> <span style="font-size: 15px; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(253, 253, 254); color: rgb(5, 7, 59); font-family: -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, Ubuntu, &quot;Helvetica Neue&quot;, Helvetica, Arial, &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei UI&quot;, &quot;Microsoft YaHei&quot;, &quot;Source Han Sans CN&quot;, sans-serif, &quot;Apple Color Emoji&quot;, &quot;Segoe UI Emoji&quot;; font-variant-caps: normal; font-variant-ligatures: normal;">SV_TARGET</span></div></li><ul><li><div><span style="font-size: 15px; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(253, 253, 254); color: rgb(5, 7, 59); font-family: -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, Ubuntu, &quot;Helvetica Neue&quot;, Helvetica, Arial, &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei UI&quot;, &quot;Microsoft YaHei&quot;, &quot;Source Han Sans CN&quot;, sans-serif, &quot;Apple Color Emoji&quot;, &quot;Segoe UI Emoji&quot;; font-variant-caps: normal; font-variant-ligatures: normal;">PO</span><span style="font-size: 15px; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(253, 253, 254); color: rgb(5, 7, 59); font-family: -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, Ubuntu, &quot;Helvetica Neue&quot;, Helvetica, Arial, &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei UI&quot;, &quot;Microsoft YaHei&quot;, &quot;Source Han Sans CN&quot;, sans-serif, &quot;Apple Color Emoji&quot;, &quot;Segoe UI Emoji&quot;; font-variant-caps: normal; font-variant-ligatures: normal;">S</span><span style="font-size: 15px; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(253, 253, 254); color: rgb(5, 7, 59); font-family: -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, Ubuntu, &quot;Helvetica Neue&quot;, Helvetica, Arial, &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei UI&quot;, &quot;Microsoft YaHei&quot;, &quot;Source Han Sans CN&quot;, sans-serif, &quot;Apple Color Emoji&quot;, &quot;Segoe UI Emoji&quot;; font-variant-caps: normal; font-variant-ligatures: normal;">ITION 代表顶点在模型空间中的位置; 作用于顶点着色器的输入</span></div></li><li><div><span style="font-size: 15px; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(253, 253, 254); color: rgb(5, 7, 59); font-family: -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, Ubuntu, &quot;Helvetica Neue&quot;, Helvetica, Arial, &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei UI&quot;, &quot;Microsoft YaHei&quot;, &quot;Source Han Sans CN&quot;, sans-serif, &quot;Apple Color Emoji&quot;, &quot;Segoe UI Emoji&quot;; font-variant-caps: normal; font-variant-ligatures: normal;">SV_PO</span><span style="font-size: 15px; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(253, 253, 254); color: rgb(5, 7, 59); font-family: -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, Ubuntu, &quot;Helvetica Neue&quot;, Helvetica, Arial, &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei UI&quot;, &quot;Microsoft YaHei&quot;, &quot;Source Han Sans CN&quot;, sans-serif, &quot;Apple Color Emoji&quot;, &quot;Segoe UI Emoji&quot;; font-variant-caps: normal; font-variant-ligatures: normal;">S</span><span style="font-size: 15px; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(253, 253, 254); color: rgb(5, 7, 59); font-family: -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, Ubuntu, &quot;Helvetica Neue&quot;, Helvetica, Arial, &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei UI&quot;, &quot;Microsoft YaHei&quot;, &quot;Source Han Sans CN&quot;, sans-serif, &quot;Apple Color Emoji&quot;, &quot;Segoe UI Emoji&quot;; font-variant-caps: normal; font-variant-ligatures: normal;">ITION 代表顶点在裁剪空间中的位置;作用于顶点着色器的输出和片元着色器的输入</span></div></li><li><div><span style="font-size: 15px; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(253, 253, 254); color: rgb(5, 7, 59); font-family: -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, Ubuntu, &quot;Helvetica Neue&quot;, Helvetica, Arial, &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei UI&quot;, &quot;Microsoft YaHei&quot;, &quot;Source Han Sans CN&quot;, sans-serif, &quot;Apple Color Emoji&quot;, &quot;Segoe UI Emoji&quot;; font-variant-caps: normal; font-variant-ligatures: normal;">SV_TARGET 代表片元着色器的输出颜色存储到渲染目标中</span></div></li></ul><li><div><span style="font-size: 11pt;">纹理: 纹理映射坐标称为UV坐标,归一化</span></div></li><ul><li><div><span style="font-size: 11pt;">warp mode 采样模式</span></div></li><li><div><span style="font-size: 11pt;">Tilling(缩放) 和 Offset(位移) ,在shader中需要使用自定 xxx_ST名称去声明</span><span style="font-size: 11pt;"><img src="Evernote_files/Image [87].png" type="image/png" data-filename="Image.png"/></span></div></li></ul></ol><div style="box-sizing: border-box; padding: 8px; font-family: Monaco, Menlo, Consolas, &quot;Courier New&quot;, monospace; font-size: 12px; color: rgb(51, 51, 51); border-radius: 4px; background-color: rgb(251, 250, 248); border: 1px solid rgba(0, 0, 0, 0.15);-en-codeblock:true;"><div>o.uv = v.texcoord.xy * _MainTex_ST.xy + _MainTex_ST.zw</div><div>等效于</div><div>o.uv = TRANSFORM_TEX(v.texcoord, _MainTex);//纹理坐标转换</div><div><br/></div><div>//从纹理中采样</div><div>fixed3 color = tex2D(_MainTex, o.uv).rgb;//从纹理中获取颜色</div></div><ol><li><div>法线</div></li><ol><li><div><span style="font-size: medium; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; color: rgb(25, 27, 31); font-family: -apple-system, BlinkMacSystemFont, &quot;Helvetica Neue&quot;, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Source Han Sans SC&quot;, &quot;Noto Sans CJK SC&quot;, &quot;WenQuanYi Micro Hei&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">法线贴图主要是为了在不增加几何细节的情况下来改变法线方向(注意模型的法线还是不变的)，使得在光照计算中可以出现一定的明暗变化，能够有更加真实的效果</span><img src="Evernote_files/Image [88].png" type="image/png" data-filename="Image.png"/></div></li></ol><li><div>切线空间</div></li><ol><li><div><span style="font-size: medium; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; color: rgb(25, 27, 31); font-family: -apple-system, BlinkMacSystemFont, &quot;Helvetica Neue&quot;, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Source Han Sans SC&quot;, &quot;Noto Sans CJK SC&quot;, &quot;WenQuanYi Micro Hei&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">切线空间是什么呢？切线空间也是一种坐标系,</span><span style="font-size: medium; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; color: rgb(25, 27, 31); font-family: -apple-system, BlinkMacSystemFont, &quot;Helvetica Neue&quot;, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Source Han Sans SC&quot;, &quot;Noto Sans CJK SC&quot;, &quot;WenQuanYi Micro Hei&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">以顶点坐标为原点并且使用顶点的法线和切线为轴构造的</span></div></li><li><div><span style="color: rgb(25, 27, 31); font-weight: bold;">切线空间用于存储法线</span></div></li><li><div><span style="color: rgb(25, 27, 31); font-weight: bold;">TBN矩阵 - 切线x副切线y法线z</span></div></li></ol><li><div>凹凸映射 - 法线贴图 : 需要将法线贴图的法线数据在切线空间中映射后再计算光照 (也可以将法线映射到裁剪空间上计算,但是比较麻烦 <a href="https://zhuanlan.zhihu.com/p/112253165">https://zhuanlan.zhihu.com/p/112253165</a>)</div></li><ol><li><div>法线贴图计算方法探究:</div></li><ul><li><div>切线空间计算光照: 将光照方向和观察方向变换到切线空间中, 这种做法效率高</div></li><li><div>世界空间计算光照: 将法线信息变换到世界空间中, 这种做法通用性高,可以做其他的计算(环境映射等)</div></li></ul><li><div>正常情况下法线映射需要手动计算,但是将Texture Type 设置为Normal_map使用unity内置<span style="font-size: medium; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; color: rgb(25, 27, 31); font-family: -apple-system, BlinkMacSystemFont, &quot;Helvetica Neue&quot;, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Source Han Sans SC&quot;, &quot;Noto Sans CJK SC&quot;, &quot;WenQuanYi Micro Hei&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">UnpackNormal函数可完成法线映射</span><span style="color: rgb(25, 27, 31);"><img src="Evernote_files/Image [89].png" type="image/png" data-filename="Image.png"/></span> <span style="color: rgb(25, 27, 31);"><img src="Evernote_files/Image [90].png" type="image/png" data-filename="Image.png"/></span></div></li></ol><li><div>遮罩纹理 - 用于高光的混合,通常一张原图的灰度图就可以作为遮罩纹理<img src="Evernote_files/Image [91].png" type="image/png" data-filename="Image.png"/></div></li></ol><div><span style="font-size: 18pt;"><span style="font-size: 18pt; color: rgb(25, 27, 31); font-weight: bold;">基础光照</span></span></div><div>Phong模型</div><div><img src="Evernote_files/Image [92].png" type="image/png" data-filename="Image.png"/></div><div><span style="font-weight: bold;">环境光 Ambient</span> 为系统变量 <span style="font-size: medium; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; color: rgb(25, 27, 31); font-family: -apple-system, BlinkMacSystemFont, &quot;Helvetica Neue&quot;, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Source Han Sans SC&quot;, &quot;Noto Sans CJK SC&quot;, &quot;WenQuanYi Micro Hei&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: bold;">UNITY_LIGHTMODEL_AMBIENT</span></div><div><span style="font-weight: bold;">漫反射</span><span style="font-size: medium; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; color: rgb(25, 27, 31); font-family: -apple-system, BlinkMacSystemFont, &quot;Helvetica Neue&quot;, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Source Han Sans SC&quot;, &quot;Noto Sans CJK SC&quot;, &quot;WenQuanYi Micro Hei&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: bold;"> </span><span style="font-size: medium; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; color: rgb(25, 27, 31); font-family: -apple-system, BlinkMacSystemFont, &quot;Helvetica Neue&quot;, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Source Han Sans SC&quot;, &quot;Noto Sans CJK SC&quot;, &quot;WenQuanYi Micro Hei&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;"><span style="font-size: medium; color: rgb(25, 27, 31); font-family: -apple-system, BlinkMacSystemFont, &quot;Helvetica Neue&quot;, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Source Han Sans SC&quot;, &quot;Noto Sans CJK SC&quot;, &quot;WenQuanYi Micro Hei&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: bold;">diffuse</span> 使用兰伯特模型 或者 半兰伯特模型 </span></div><div><span style="color: rgb(25, 27, 31);"><img src="Evernote_files/Image [93].png" type="image/png" data-filename="Image.png"/></span><span style="color: rgb(25, 27, 31);"><img src="Evernote_files/Image [94].png" type="image/png" data-filename="Image.png"/>需要将余弦计算结果控制在[0,1]之间</span></div><div><span style="color: rgb(25, 27, 31);"><img src="Evernote_files/Image [95].png" type="image/png" data-filename="Image.png"/></span></div><div><span style="color: rgb(25, 27, 31);"><span style="color: rgb(25, 27, 31); font-weight: bold;">高光 Specular </span>  </span><span style="color: rgb(25, 27, 31); font-family: -apple-system, BlinkMacSystemFont, &quot;Helvetica Neue&quot;, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Source Han Sans SC&quot;, &quot;Noto Sans CJK SC&quot;, &quot;WenQuanYi Micro Hei&quot;, sans-serif;">Phong光照模型 : 它通过以下的公式来计算高光;</span><span style="background-color: rgb(255, 255, 255); color: rgb(25, 27, 31); font-family: -apple-system, BlinkMacSystemFont, &quot;Helvetica Neue&quot;, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Source Han Sans SC&quot;, &quot;Noto Sans CJK SC&quot;, &quot;WenQuanYi Micro Hei&quot;, sans-serif;">其中</span><span style="background-color: rgb(255, 255, 255); color: rgb(25, 27, 31); font-family: -apple-system, BlinkMacSystemFont, &quot;Helvetica Neue&quot;, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Source Han Sans SC&quot;, &quot;Noto Sans CJK SC&quot;, &quot;WenQuanYi Micro Hei&quot;, sans-serif; font-weight: bold;">I</span><span style="background-color: rgb(255, 255, 255); color: rgb(25, 27, 31); font-family: -apple-system, BlinkMacSystemFont, &quot;Helvetica Neue&quot;, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Source Han Sans SC&quot;, &quot;Noto Sans CJK SC&quot;, &quot;WenQuanYi Micro Hei&quot;, sans-serif;">是光源信息</span><span style="background-color: rgb(255, 255, 255); color: rgb(25, 27, 31); font-family: -apple-system, BlinkMacSystemFont, &quot;Helvetica Neue&quot;, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Source Han Sans SC&quot;, &quot;Noto Sans CJK SC&quot;, &quot;WenQuanYi Micro Hei&quot;, sans-serif; font-weight: bold;">，r</span><span style="background-color: rgb(255, 255, 255); color: rgb(25, 27, 31); font-family: -apple-system, BlinkMacSystemFont, &quot;Helvetica Neue&quot;, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Source Han Sans SC&quot;, &quot;Noto Sans CJK SC&quot;, &quot;WenQuanYi Micro Hei&quot;, sans-serif;">是反射方向</span><span style="background-color: rgb(255, 255, 255); color: rgb(25, 27, 31); font-family: -apple-system, BlinkMacSystemFont, &quot;Helvetica Neue&quot;, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Source Han Sans SC&quot;, &quot;Noto Sans CJK SC&quot;, &quot;WenQuanYi Micro Hei&quot;, sans-serif; font-weight: bold;">，v</span><span style="background-color: rgb(255, 255, 255); color: rgb(25, 27, 31); font-family: -apple-system, BlinkMacSystemFont, &quot;Helvetica Neue&quot;, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Source Han Sans SC&quot;, &quot;Noto Sans CJK SC&quot;, &quot;WenQuanYi Micro Hei&quot;, sans-serif;">是视角方向</span><span style="background-color: rgb(255, 255, 255); color: rgb(25, 27, 31); font-family: -apple-system, BlinkMacSystemFont, &quot;Helvetica Neue&quot;, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Source Han Sans SC&quot;, &quot;Noto Sans CJK SC&quot;, &quot;WenQuanYi Micro Hei&quot;, sans-serif; font-weight: bold;">，gloss</span><span style="background-color: rgb(255, 255, 255); color: rgb(25, 27, 31); font-family: -apple-system, BlinkMacSystemFont, &quot;Helvetica Neue&quot;, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Source Han Sans SC&quot;, &quot;Noto Sans CJK SC&quot;, &quot;WenQuanYi Micro Hei&quot;, sans-serif;">是光滑度</span><span style="color: rgb(25, 27, 31); font-family: -apple-system, BlinkMacSystemFont, &quot;Helvetica Neue&quot;, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Source Han Sans SC&quot;, &quot;Noto Sans CJK SC&quot;, &quot;WenQuanYi Micro Hei&quot;, sans-serif; font-weight: bold;">。</span><span style="color: rgb(25, 27, 31);"><img src="Evernote_files/Image [96].png" type="image/png" data-filename="Image.png"/></span><img src="Evernote_files/Image [97].png" type="image/png" data-filename="Image.png"/> L为入射光方向</div><div>     <span style="font-size: medium; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; color: rgb(83, 88, 97); font-family: -apple-system, BlinkMacSystemFont, &quot;Helvetica Neue&quot;, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Source Han Sans SC&quot;, &quot;Noto Sans CJK SC&quot;, &quot;WenQuanYi Micro Hei&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">Bling-Phong模型 : </span>半程分量 : 光源向量 和 视角向量的 <span style="font-size: medium; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; color: rgb(25, 27, 31); font-family: -apple-system, BlinkMacSystemFont, &quot;Helvetica Neue&quot;, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Source Han Sans SC&quot;, &quot;Noto Sans CJK SC&quot;, &quot;WenQuanYi Micro Hei&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">角平分向量h </span></div><div style="top: 0px; left: 0px; clip: rect(1px 1px 1px 1px); user-select: none; transition: none; position: absolute !important; padding: 1px 0px 0px !important; border: 0px !important; height: 1px !important; width: 1px !important; overflow: hidden !important;"><span style="top: 0px; clip: rect(1px 1px 1px 1px); user-select: none; position: relative; border: 0px; font-size: 16px; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: normal; -webkit-text-stroke-width: 0px; white-space: nowrap; display: inline-block; overflow-wrap: normal; direction: ltr; max-width: none; max-height: none; min-width: 0px; min-height: 0px; height: 1px !important; width: 1px !important; overflow: hidden !important; color: rgb(25, 27, 31); font-family: -apple-system, BlinkMacSystemFont, &quot;Helvetica Neue&quot;, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Source Han Sans SC&quot;, &quot;Noto Sans CJK SC&quot;, &quot;WenQuanYi Micro Hei&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; line-height: normal;">h</span></div><div style="top: 0px; left: 0px; clip: rect(1px 1px 1px 1px); user-select: none; transition: none; position: absolute !important; padding: 1px 0px 0px !important; border: 0px !important; height: 1px !important; width: 1px !important; overflow: hidden !important;"><span style="top: 0px; clip: rect(1px 1px 1px 1px); user-select: none; position: relative; border: 0px; font-size: 16px; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: normal; -webkit-text-stroke-width: 0px; white-space: nowrap; display: inline-block; overflow-wrap: normal; direction: ltr; max-width: none; max-height: none; min-width: 0px; min-height: 0px; height: 1px !important; width: 1px !important; overflow: hidden !important; color: rgb(25, 27, 31); font-family: -apple-system, BlinkMacSystemFont, &quot;Helvetica Neue&quot;, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Source Han Sans SC&quot;, &quot;Noto Sans CJK SC&quot;, &quot;WenQuanYi Micro Hei&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; line-height: normal;">h</span></div><div><img src="Evernote_files/Image [98].png" type="image/png" data-filename="Image.png"/></div><p style="margin: 1.4em 0px; color: rgb(25, 27, 31); font-family: -apple-system, BlinkMacSystemFont, &quot;Helvetica Neue&quot;, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Source Han Sans SC&quot;, &quot;Noto Sans CJK SC&quot;, &quot;WenQuanYi Micro Hei&quot;, sans-serif; font-size: medium; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255);"></p><div style="top: 0px; left: 0px; clip: rect(1px 1px 1px 1px); user-select: none; transition: none; position: absolute !important; padding: 1px 0px 0px !important; border: 0px !important; height: 1px !important; width: 1px !important; overflow: hidden !important;"><span style="top: 0px; clip: rect(1px 1px 1px 1px); user-select: none; position: relative; border: 0px; display: inline-block; font-size: 16px; text-indent: 0px; text-transform: none; letter-spacing: normal; word-spacing: normal; overflow-wrap: normal; white-space: nowrap; direction: ltr; max-width: none; max-height: none; min-width: 0px; min-height: 0px; height: 1px !important; width: 1px !important; overflow: hidden !important; line-height: normal;">specular=I∗max(0,r→⋅v→)gloss</span></div><div style="margin: 1.4em 0px; font-size: medium; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal;"><br/></div><h1 style="font-size: 24px; margin: 24px 0px; overflow-wrap: break-word; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255);"><span style="font-size: 24px; overflow-wrap: break-word; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; color: rgb(25, 27, 31); font-family: -apple-system, BlinkMacSystemFont, &quot;Helvetica Neue&quot;, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Source Han Sans SC&quot;, &quot;Noto Sans CJK SC&quot;, &quot;WenQuanYi Micro Hei&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: bold; line-height: 1.22;">透明效果</span></h1><div><span style="color: rgb(25, 27, 31);">需要掌握 <span style="color: rgb(25, 27, 31); font-weight: bold;">渲染顺序 和 混合模式</span></span></div><div><span style="color: rgb(25, 27, 31);"><span style="color: rgb(25, 27, 31); font-weight: bold;">渲染顺序:</span> </span> <span style="font-size: medium; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; color: rgb(25, 27, 31); font-family: -apple-system, BlinkMacSystemFont, &quot;Helvetica Neue&quot;, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Source Han Sans SC&quot;, &quot;Noto Sans CJK SC&quot;, &quot;WenQuanYi Micro Hei&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">先渲染不透明的物体，再渲染半透明的物体。在半透明物体中，我们先渲染离相机更远的物体，再渲染离相机更近的物体。</span></div><div><span style="font-size: medium; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; color: rgb(25, 27, 31); font-family: -apple-system, BlinkMacSystemFont, &quot;Helvetica Neue&quot;, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Source Han Sans SC&quot;, &quot;Noto Sans CJK SC&quot;, &quot;WenQuanYi Micro Hei&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">当渲染半透明物体的时候，使用半透明混合和不透明物体的颜色进行</span><span style="font-size: medium; color: rgb(25, 27, 31); font-family: -apple-system, BlinkMacSystemFont, &quot;Helvetica Neue&quot;, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Source Han Sans SC&quot;, &quot;Noto Sans CJK SC&quot;, &quot;WenQuanYi Micro Hei&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: bold;">混合</span><span style="font-size: medium; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; color: rgb(25, 27, 31); font-family: -apple-system, BlinkMacSystemFont, &quot;Helvetica Neue&quot;, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Source Han Sans SC&quot;, &quot;Noto Sans CJK SC&quot;, &quot;WenQuanYi Micro Hei&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">。</span></div><div><span style="font-size: medium; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal;"><br/></span></div><div><span style="font-weight: bold;">深度缓冲区</span> :存储了每个像素的深度信息,即每个像素离摄像机的远近,这个值是由模型的顶点z值 转化得到的，归一化到0和1之间。不是这个值不是线性的, 离摄像机近的物体具有更高的精度，而离摄像机远的物体则具有较低的精度</div><div><span style="font-weight: bold;">工作机制:</span></div><ul><li><div><span style="font-weight: bold;">获取当前像素点的深度值 :</span> 通常由顶点着色器计算深度值,在片元着色器阶段更新</div></li><li><div><span style="font-weight: bold;">对比深度值:</span> 将这个深度值与深度缓冲中对应像素位置的深度值进行比较。如果当前像素的深度值小于深度缓冲中的值（即当前像素离摄像机更近），则执行下一步；否则，该像素将被丢弃，不进行后续的渲染操作。</div></li><li><div><span style="font-weight: bold;">更新深度缓冲</span>：如果当前像素通过了深度测试，则将其深度值写入到深度缓冲中，并继续执行后续的渲染操作（如颜色混合等）。</div></li></ul><div><br/></div><div><span style="font-weight: bold;">为什么半透明物体需要将深度写入关闭?</span>  在渲染半透明物体时，如果开启深度写入，可能会导致深度缓冲的工作机制被破坏，从而无法正确渲染半透明物体背后的表面。 如果一个半透明物体表面背后的表面本来是可以透过它被我们看到的，但由于深度测试时判断该半透明表面距离摄像机更近，导致后面的表面被剔除，那么我们就无法通过半透明表面看到后面的物体。</div><div><br/></div><div>混合模式指令</div><div><img src="Evernote_files/Image [99].png" type="image/png" data-filename="Image.png"/>探究 <span style="font-size: medium; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; color: rgb(25, 27, 31); font-family: -apple-system, BlinkMacSystemFont, &quot;Helvetica Neue&quot;, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Source Han Sans SC&quot;, &quot;Noto Sans CJK SC&quot;, &quot;WenQuanYi Micro Hei&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">Blend SrcFactor DstFactor  - 两个参数因子 </span> <span style="background: rgb(255, 250, 165); border-radius: 0px; font-size: 0.9em; overflow: auto; white-space: pre; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; color: rgb(25, 27, 31); font-family: Menlo, Monaco, Consolas, &quot;Andale Mono&quot;, &quot;lucida console&quot;, &quot;Courier New&quot;, monospace; font-variant-caps: normal; font-variant-ligatures: normal;">Blend SrcAlpha OneMinusSrcAlpha</span> 实现半透明效果,其他因子代表的意义<img src="Evernote_files/Image [100].png" type="image/png" data-filename="Image.png"/> <img src="https://pic4.zhimg.com/v2-d0c9260dc43956d63e70389d36c30f39_1440w.jpg"></img> <img src="Evernote_files/Image [101].png" type="image/png" data-filename="Image.png"/></div><div>反射</div><div>实现原理: 相机视角和物体的法线计算反射方向;通过反射方向在cubeMap中进行采样;采样值和主纹理进行 <b>线性插值</b><b><img src="Evernote_files/Image [102].png" type="image/png" data-filename="Image.png"/></b></div><div>的</div><div><br/></div><div><br/></div></div><div><br/></div></span>
</div>
<hr>
<a name="726"/>

<div>
<span><div><div><span style="font-size: 11pt; color: rgb(5, 7, 59);">踩坑记录</span></div><div>最终渲染效果偏粉可能的原因 : <span style="background-color: rgb(255, 250, 165);-evernote-highlight:true;"><span style="font-size: 15px; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 250, 165); color: rgb(5, 7, 59); font-family: -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, Ubuntu, &quot;Helvetica Neue&quot;, Helvetica, Arial, &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei UI&quot;, &quot;Microsoft YaHei&quot;, &quot;Source Han Sans CN&quot;, sans-serif, &quot;Apple Color Emoji&quot;, &quot;Segoe UI Emoji&quot;; font-variant-caps: normal; font-variant-ligatures: normal;-evernote-highlight:true;">使用了</span><span style="font-size: 15px; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 250, 165); color: rgb(5, 7, 59); font-family: -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, Ubuntu, &quot;Helvetica Neue&quot;, Helvetica, Arial, &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei UI&quot;, &quot;Microsoft YaHei&quot;, &quot;Source Han Sans CN&quot;, sans-serif, &quot;Apple Color Emoji&quot;, &quot;Segoe UI Emoji&quot;; font-variant-caps: normal; font-variant-ligatures: normal;-evernote-highlight:true;"> </span><span style="box-sizing: border-box; -webkit-font-smoothing: antialiased; font-size: 12.75px; tab-size: 4; border-radius: 3px; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 250, 165); color: rgb(5, 7, 59); font-family: SFMono-Regular, Consolas, &quot;Liberation Mono&quot;, Menlo, Courier, monospace; font-variant-caps: normal; font-variant-ligatures: normal;-evernote-highlight:true;">.rbg</span><span style="font-size: 15px; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 250, 165); color: rgb(5, 7, 59); font-family: -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, Ubuntu, &quot;Helvetica Neue&quot;, Helvetica, Arial, &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei UI&quot;, &quot;Microsoft YaHei&quot;, &quot;Source Han Sans CN&quot;, sans-serif, &quot;Apple Color Emoji&quot;, &quot;Segoe UI Emoji&quot;; font-variant-caps: normal; font-variant-ligatures: normal;-evernote-highlight:true;"> </span><span style="font-size: 15px; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 250, 165); color: rgb(5, 7, 59); font-family: -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, Ubuntu, &quot;Helvetica Neue&quot;, Helvetica, Arial, &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei UI&quot;, &quot;Microsoft YaHei&quot;, &quot;Source Han Sans CN&quot;, sans-serif, &quot;Apple Color Emoji&quot;, &quot;Segoe UI Emoji&quot;; font-variant-caps: normal; font-variant-ligatures: normal;-evernote-highlight:true;">而不是</span><span style="font-size: 15px; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 250, 165); color: rgb(5, 7, 59); font-family: -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, Ubuntu, &quot;Helvetica Neue&quot;, Helvetica, Arial, &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei UI&quot;, &quot;Microsoft YaHei&quot;, &quot;Source Han Sans CN&quot;, sans-serif, &quot;Apple Color Emoji&quot;, &quot;Segoe UI Emoji&quot;; font-variant-caps: normal; font-variant-ligatures: normal;-evernote-highlight:true;"> </span><span style="box-sizing: border-box; -webkit-font-smoothing: antialiased; font-size: 12.75px; tab-size: 4; border-radius: 3px; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 250, 165); color: rgb(5, 7, 59); font-family: SFMono-Regular, Consolas, &quot;Liberation Mono&quot;, Menlo, Courier, monospace; font-variant-caps: normal; font-variant-ligatures: normal;-evernote-highlight:true;">.rgb</span></span><span style="font-size: 15px; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(253, 253, 254); color: rgb(5, 7, 59); font-family: -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, Ubuntu, &quot;Helvetica Neue&quot;, Helvetica, Arial, &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei UI&quot;, &quot;Microsoft YaHei&quot;, &quot;Source Han Sans CN&quot;, sans-serif, &quot;Apple Color Emoji&quot;, &quot;Segoe UI Emoji&quot;; font-variant-caps: normal; font-variant-ligatures: normal;">。在 ShaderLab（HLSL/GLSL）中，颜色分量应正确命名为</span><span style="font-size: 15px; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(253, 253, 254); color: rgb(5, 7, 59); font-family: -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, Ubuntu, &quot;Helvetica Neue&quot;, Helvetica, Arial, &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei UI&quot;, &quot;Microsoft YaHei&quot;, &quot;Source Han Sans CN&quot;, sans-serif, &quot;Apple Color Emoji&quot;, &quot;Segoe UI Emoji&quot;; font-variant-caps: normal; font-variant-ligatures: normal;"> </span><span style="box-sizing: border-box; -webkit-font-smoothing: antialiased; font-size: 12.75px; tab-size: 4; background-color: rgba(27, 31, 35, 0.05); border-radius: 3px; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; color: rgb(5, 7, 59); font-family: SFMono-Regular, Consolas, &quot;Liberation Mono&quot;, Menlo, Courier, monospace; font-variant-caps: normal; font-variant-ligatures: normal;">r</span><span style="font-size: 15px; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(253, 253, 254); color: rgb(5, 7, 59); font-family: -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, Ubuntu, &quot;Helvetica Neue&quot;, Helvetica, Arial, &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei UI&quot;, &quot;Microsoft YaHei&quot;, &quot;Source Han Sans CN&quot;, sans-serif, &quot;Apple Color Emoji&quot;, &quot;Segoe UI Emoji&quot;; font-variant-caps: normal; font-variant-ligatures: normal;">（红）、</span><span style="box-sizing: border-box; -webkit-font-smoothing: antialiased; font-size: 12.75px; tab-size: 4; background-color: rgba(27, 31, 35, 0.05); border-radius: 3px; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; color: rgb(5, 7, 59); font-family: SFMono-Regular, Consolas, &quot;Liberation Mono&quot;, Menlo, Courier, monospace; font-variant-caps: normal; font-variant-ligatures: normal;">g</span><span style="font-size: 15px; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(253, 253, 254); color: rgb(5, 7, 59); font-family: -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, Ubuntu, &quot;Helvetica Neue&quot;, Helvetica, Arial, &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei UI&quot;, &quot;Microsoft YaHei&quot;, &quot;Source Han Sans CN&quot;, sans-serif, &quot;Apple Color Emoji&quot;, &quot;Segoe UI Emoji&quot;; font-variant-caps: normal; font-variant-ligatures: normal;">（绿）、</span><span style="box-sizing: border-box; -webkit-font-smoothing: antialiased; font-size: 12.75px; tab-size: 4; background-color: rgba(27, 31, 35, 0.05); border-radius: 3px; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; color: rgb(5, 7, 59); font-family: SFMono-Regular, Consolas, &quot;Liberation Mono&quot;, Menlo, Courier, monospace; font-variant-caps: normal; font-variant-ligatures: normal;">b</span><span style="font-size: 15px; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(253, 253, 254); color: rgb(5, 7, 59); font-family: -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, Ubuntu, &quot;Helvetica Neue&quot;, Helvetica, Arial, &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei UI&quot;, &quot;Microsoft YaHei&quot;, &quot;Source Han Sans CN&quot;, sans-serif, &quot;Apple Color Emoji&quot;, &quot;Segoe UI Emoji&quot;; font-variant-caps: normal; font-variant-ligatures: normal;">（蓝）。错误地使用</span><span style="font-size: 15px; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(253, 253, 254); color: rgb(5, 7, 59); font-family: -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, Ubuntu, &quot;Helvetica Neue&quot;, Helvetica, Arial, &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei UI&quot;, &quot;Microsoft YaHei&quot;, &quot;Source Han Sans CN&quot;, sans-serif, &quot;Apple Color Emoji&quot;, &quot;Segoe UI Emoji&quot;; font-variant-caps: normal; font-variant-ligatures: normal;"> </span><span style="box-sizing: border-box; -webkit-font-smoothing: antialiased; font-size: 12.75px; tab-size: 4; background-color: rgba(27, 31, 35, 0.05); border-radius: 3px; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; color: rgb(5, 7, 59); font-family: SFMono-Regular, Consolas, &quot;Liberation Mono&quot;, Menlo, Courier, monospace; font-variant-caps: normal; font-variant-ligatures: normal;">.rbg</span><span style="font-size: 15px; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(253, 253, 254); color: rgb(5, 7, 59); font-family: -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, Ubuntu, &quot;Helvetica Neue&quot;, Helvetica, Arial, &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei UI&quot;, &quot;Microsoft YaHei&quot;, &quot;Source Han Sans CN&quot;, sans-serif, &quot;Apple Color Emoji&quot;, &quot;Segoe UI Emoji&quot;; font-variant-caps: normal; font-variant-ligatures: normal;"> </span><span style="font-size: 15px; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(253, 253, 254); color: rgb(5, 7, 59); font-family: -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, Ubuntu, &quot;Helvetica Neue&quot;, Helvetica, Arial, &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei UI&quot;, &quot;Microsoft YaHei&quot;, &quot;Source Han Sans CN&quot;, sans-serif, &quot;Apple Color Emoji&quot;, &quot;Segoe UI Emoji&quot;; font-variant-caps: normal; font-variant-ligatures: normal;">可能会导致某些颜色通道被错误地读取或解释</span></div><div><span style="font-size: 15px; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(253, 253, 254);"><br/></span></div><div><span style="font-size: 11pt; color: rgb(5, 7, 59);">所有向量参数都需要归一化</span></div><div><span style="font-size: 11pt;"><br/></span></div><div><span style="font-size: 11pt; color: rgb(5, 7, 59);">计算向量点乘后需要</span><span style="font-size: 11pt; color: rgb(5, 7, 59);">saturate()</span><span style="font-size: 11pt; color: rgb(5, 7, 59);">确保结果不会变成负数</span></div><div><span style="font-size: 11pt;"><br/></span></div><div><span style="font-size: 11pt; color: rgb(5, 7, 59);">半兰伯特模型的计算注意要点 offset的值需要先加,否则最终渲染效果会偏亮</span></div><div style="box-sizing: border-box; padding: 8px; font-family: Monaco, Menlo, Consolas, &quot;Courier New&quot;, monospace; font-size: 12px; color: rgb(51, 51, 51); border-radius: 4px; background-color: rgb(251, 250, 248); border: 1px solid rgba(0, 0, 0, 0.15);-en-codeblock:true;"><div>fixed3 diffuse = _LightColor0.rgb  *_DiffuseColor.rgb *baseColor*</div><div>    (dot(normal,lightDir) * 0.5 + 0.5);</div></div><div><br/></div><div><span style="font-size: 11pt;">TBN矩阵计算副切线需要将向量归一化</span></div><div style="box-sizing: border-box; padding: 8px; font-family: Monaco, Menlo, Consolas, &quot;Courier New&quot;, monospace; font-size: 12px; color: rgb(51, 51, 51); border-radius: 4px; background-color: rgb(251, 250, 248); border: 1px solid rgba(0, 0, 0, 0.15);-en-codeblock:true;"><div>float3 binormal  = cross(normalize(v.normal),normalize(v.tangent)) * v.tangent.w;</div></div><div><br/></div><div>在切线空间计算法线贴图时,需要明确的是将模型空间光线方向转到切线空间</div><div><br/></div><div>数据计算是放在片元还是顶点的呢?比如视角方向,反射方向等; <span style="font-weight: bold;">计算数据放在顶点着色器中</span>!!! 原因有二:</div><ol><li><div>顶点着色器计算次数远少于片元着色器;比如一个三角形,顶点着色器只会调用三次,但是片元着色器会依据三角形内部像素调用多次<b>照成性能问题</b></div></li><li><div>顶点着色器数据向片元着色器传递的数据是通过插值的方式,一些基于顶点的数据计算的向量,在片元着色器插值过程会<b>照成精度误差</b></div></li></ol><div>需要依据情况而定,比如漫反射在片元着色器中计算效果就更好,因为数据插值使过渡更平滑</div><div><br/></div></div><div><br/></div></span>
</div>
<hr>
<a name="744"/>

<div>
<span><div>小地图相关</div><div>点击小地图定位到大地图的点位:</div><div>获得点击的屏幕坐标 =&gt; UGUI坐标=&gt;世界坐标 <a href="https://www.jianshu.com/p/31df553a51a8">https://www.jianshu.com/p/31df553a51a8</a></div><div><br/></div></span>
</div>
<hr>
<a name="745"/>

<div>
<span><div>客户端协议处理流程</div><div>底层使用 tcp协议通信; 通信内容是固定格式: 主协议号 + 子协议号 + 数据包byte[]</div><div>发送流程: 具体协议类 =&gt; byte[],添加到发送队列</div><div>接收流程: 处理粘包,获取完整的协议数据byte[],解析成具体的协议类,分发到对应的协议处理类中处理</div><div>    协议分发机制: 先依据主协议号获取该组的协议处理器;然后依据子协议分发到对应的子协议处理模块处理</div><div><br/></div><div>阵营战中的网络同步</div><div>每隔0.5秒(请求-接收途中不计时)发送一条协议请求增量消息,服务端回包的内容是所有有变更数据的协议</div><div>    发送步骤: 118_002为操作协议战场客户端所有类型的请求数据都通过该协议发送,请求增量信息时将001_005作为118_002的retProto发送给服务端</div><div><img src="Evernote_files/Image [103].png" type="image/png" data-filename="Image.png"/><img src="Evernote_files/Image [104].png" type="image/png" data-filename="Image.png"/>    接收步骤: 118_002回包后解析出retProto的实际内容001_005增量Raid_Msg消息列表,消息列表可解析成对应的协议,然后再走正常的协议分发处理<img src="Evernote_files/Image [105].png" type="image/png" data-filename="Image.png" width="569"/></div><div><img src="Evernote_files/Image [106].png" type="image/png" data-filename="Image.png"/>序列号同步机制: 发送协议时可以附带回包回调,在回包后分发消息后执行</div><div><br/></div><div><br/></div><div><br/></div><div><br/></div></span>
</div>
<hr>
<a name="750"/>

<div>
<span><div>范型随笔</div><div>目前将范型类在进行抽象行为组织时,引用该类会存在问题 :由于范型类的开放属性,不能作为父类成员,1.需要写一个封闭类型的父类,将子类共有方法整合到该类中;2.接着又开放出范型类供子类派生;  ====&gt; 是否能用接口的思想进行改进呢?1.将共有方法抽象成接口去代替实现封闭类型的父类 2.或者接口的逆变协变?</div><div><img src="Evernote_files/Image [107].png" type="image/png" data-filename="Image.png"/></div><div><br/></div><div><img src="Evernote_files/Image [108].png" type="image/png" data-filename="Image.png"/></div><div><img src="Evernote_files/Image [109].png" type="image/png" data-filename="Image.png"/></div><div><br/></div><div><br/></div><div><img src="Evernote_files/Image [110].png" type="image/png" data-filename="Image.png"/></div><div><br/></div></span>
</div>
<hr>
<a name="755"/>

<div>
<span><div>递归技巧</div><div>场景1: 一系列奖励需要依次弹出;可以使用递归的方式处理,入参为当<u>前数据索引和总奖励列表;</u>结束设定为索引到总奖励列表最尾端;每次递归当前数据索引都自增</div><div style="box-sizing: border-box; padding: 8px; font-family: Monaco, Menlo, Consolas, &quot;Courier New&quot;, monospace; font-size: 12px; color: rgb(51, 51, 51); border-radius: 4px; background-color: rgb(251, 250, 248); border: 1px solid rgba(0, 0, 0, 0.15);-en-codeblock:true;"><div>private void <b>_showGainItem</b>(int _index,List&lt;Common_ItemList&gt;  _commonItemLists)</div><div>{</div><div>    if(_commonItemLists == null || _index &gt;= _commonItemLists.Count)</div><div>       return;</div><div>    int curIndex = _index;</div><div>    NPPlayer.instance.getItemNoticeMgr.addNotice(_commonItemLists[curIndex].getItemList(), _showDone: () =&gt;</div><div>    {</div><div>       <b>_showGainItem</b>(++curIndex,_commonItemLists);</div><div>    });</div><div>}</div></div><div><br/></div></span>
</div>
<hr>
<a name="756"/>

<div>
<span><div>Canvas todo</div><div><a href="https://juejin.cn/post/6990618605771718664">https://juejin.cn/post/6990618605771718664</a></div></span>
</div>
<hr>
<a name="761"/>

<div>
<span><div>排列组合</div><div>【如何理解排列组合？】 <a href="https://www.bilibili.com/video/BV1bm411m7Dp/?share_source=copy_web&amp;vd_source=e730e98e79aa537aeb9b71e050e79bde">https://www.bilibili.com/video/BV1bm411m7Dp/?share_source=copy_web&amp;vd_source=e730e98e79aa537aeb9b71e050e79bde</a></div><div><a href="https://www.cnblogs.com/1024th/p/10623541.html">排列组合的一些公式及推导(非常详细易懂) - 樱花赞 - 博客园</a></div><div>排列数</div><div><img src="Evernote_files/Image [111].png" type="image/png" data-filename="Image.png"/></div><div>组合数</div><div><br/></div><div><span style="font-size: 12pt; color: rgb(49, 70, 89); font-family: &quot;Fira Mono&quot;;"><img src="Evernote_files/Image [112].png" type="image/png" data-filename="Image.png"/></span></div></span>
</div>
<hr>
<a name="769"/>

<div>
<span><div>!!!游戏技能</div><div><a href="https://www.redblobgames.com/">https://www.redblobgames.com/</a></div><div><a href="https://catlikecoding.com/unity/tutorials/">https://catlikecoding.com/unity/tutorials/</a></div><div>待探究 文本内镶嵌图片的方案</div></span>
</div>
<hr>
<a name="770"/>

<div>
<span><div><div>gitHub轮子收集</div><div><br/></div><div><span style="font-size: 15px; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: pre-line; background-color: rgb(255, 255, 255); color: rgb(24, 25, 28); font-family: -apple-system, BlinkMacSystemFont, &quot;Helvetica Neue&quot;, Helvetica, Arial, &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">ARPG项目历时八个月，完成了包括但不限于玩家状态机、敌人行为树AI、锁定视角切换、连招系统、技能系统、Buff系统、魔女时间、对话系统、物品和背包系统、交易系统、任务系统等功能，可视化编辑器基本覆盖业务系统，进行了部分性能优化 项目GitHub地址：<a href="https://github.com/Kirin0v0/ARPG-Demo" style="background-color: rgb(255, 255, 255); font-family: -apple-system, BlinkMacSystemFont, &quot;Helvetica Neue&quot;, Helvetica, Arial, &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, sans-serif; font-size: 15px; font-variant-caps: normal; font-variant-ligatures: normal;">https://github.com/Kirin0v0/ARPG-Demo</a></span></div><div><br/></div><div><span style="color: rgb(24, 25, 28); font-family: -apple-system, BlinkMacSystemFont, &quot;Helvetica Neue&quot;, Helvetica, Arial, &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, sans-serif; font-size: 15px; font-variant-caps: normal; font-variant-ligatures: normal; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: pre-line;">YIUI框架Git地址:</span> <a href="https://github.com/LiShengYang-yiyi/YIUI.git" style="font-family: -apple-system, BlinkMacSystemFont, &quot;Helvetica Neue&quot;, Helvetica, Arial, &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, sans-serif; font-size: 15px; font-variant-caps: normal; font-variant-ligatures: normal;">https://github.com/LiShengYang-yiyi/YIUI.git</a> <span style="color: rgb(24, 25, 28); font-family: -apple-system, BlinkMacSystemFont, &quot;Helvetica Neue&quot;, Helvetica, Arial, &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, sans-serif; font-size: 15px; font-variant-caps: normal; font-variant-ligatures: normal; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: pre-line;">YIUI框架讨论群: 833479762</span></div><div><br/></div><div><br/></div><div>c# promise <a href="https://github.com/Real-Serious-Games/C-Sharp-Promise" style="font-size: unset; font-family: unset;">https://github.com/Real-Serious-Games/C-Sharp-Promise</a></div><div>lite-fsm   <a href="https://github.com/redbluegames/unity-lite-fsm">https://github.com/redbluegames/unity-lite-fsm</a></div><div><br/></div><div>unity资源加载方案库 <a href="https://github.com/killop/UnityResourceSolution">https://github.com/killop/UnityResourceSolution</a></div><h1 style="box-sizing: border-box; margin-right: 0px; margin-bottom: var(--base-size-16); margin-left: 0px; padding-bottom: 0.3em; border-bottom: 1px solid var(--borderColor-muted, var(--color-border-muted)); letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; margin-top: 0px !important;"><span style="font-size: 12pt; color: rgb(31, 35, 40); font-family: -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, &quot;Noto Sans&quot;, Helvetica, Arial, sans-serif, &quot;Apple Color Emoji&quot;, &quot;Segoe UI Emoji&quot;; font-variant-caps: normal; font-variant-ligatures: normal; line-height: 1.25;">UnitySocketPtotobuf3Demo </span><a href="https://github.com/Mikejinhua/UnitySocketProtobuf3Demo" style="font-size: 12pt; font-family: -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, &quot;Noto Sans&quot;, Helvetica, Arial, sans-serif, &quot;Apple Color Emoji&quot;, &quot;Segoe UI Emoji&quot;; font-variant-caps: normal; font-variant-ligatures: normal; line-height: 1.25;">https://github.com/Mikejinhua/UnitySocketProtobuf3Demo</a></h1><h1 style="box-sizing: border-box; margin-right: 0px; margin-bottom: var(--base-size-16); margin-left: 0px; padding-bottom: 0.3em; border-bottom: 1px solid var(--borderColor-muted, var(--color-border-muted)); letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255); margin-top: 0px !important;"><span style="box-sizing: border-box; border-bottom: 1px solid var(--borderColor-muted, var(--color-border-muted)); letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal;"><span style="font-size: 12pt; color: rgb(31, 35, 40); font-family: -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, &quot;Noto Sans&quot;, Helvetica, Arial, sans-serif, &quot;Apple Color Emoji&quot;, &quot;Segoe UI Emoji&quot;; font-variant-caps: normal; font-variant-ligatures: normal; line-height: 1.25;">终极 2D 控制器</span></span></h1><div><a href="https://github.com/Matthew-J-Spencer/Ultimate-2D-Controller" style="font-size: 12pt;">https://github.com/Matthew-J-Spencer/Ultimate-2D-Controller</a></div><h1 style="box-sizing: border-box; margin-right: 0px; margin-bottom: var(--base-size-16); margin-left: 0px; padding-bottom: 0.3em; border-bottom: 1px solid var(--borderColor-muted, var(--color-border-muted)); letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255); margin-top: 0px !important;"><span style="box-sizing: border-box; border-bottom: 1px solid var(--borderColor-muted, var(--color-border-muted)); letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal;"><span style="font-size: 12pt; color: rgb(31, 35, 40); font-family: -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, &quot;Noto Sans&quot;, Helvetica, Arial, sans-serif, &quot;Apple Color Emoji&quot;, &quot;Segoe UI Emoji&quot;; font-variant-caps: normal; font-variant-ligatures: normal; line-height: 1.25;">Unity 计时器</span></span></h1><div><a href="https://github.com/akbiggs/UnityTimer" style="font-size: 12pt;">https://github.com/akbiggs/UnityTimer</a></div><div><br/></div><div><span style="color: rgb(31, 35, 40);">F8GameFrame</span></div><div><br/></div><div><span style="color: rgb(31, 35, 40);">设计模式</span></div><div><a href="https://github.com/sheng-jie/Design-Pattern">https://github.com/sheng-jie/Design-Pattern</a></div><div><a href="https://github.com/QianMo/Unity-Design-Pattern.git">https://github.com/QianMo/Unity-Design-Pattern.git</a></div><div><br/></div><div><span style="font-size: 20px; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(246, 248, 250); color: rgb(9, 105, 218); font-family: -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, &quot;Noto Sans&quot;, Helvetica, Arial, sans-serif, &quot;Apple Color Emoji&quot;, &quot;Segoe UI Emoji&quot;; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: bold;">ExcelToSQLite4Unity3d</span></div><div><a href="https://github.com/SamuelCSM/ExcelToSQLite4Unity3d.git">https://github.com/SamuelCSM/ExcelToSQLite4Unity3d.git</a></div></div><div><br/></div><div>计算几何库</div><div><a href="https://github.com/Habrador/Computational-geometry">https://github.com/Habrador/Computational-geometry</a></div><div><br/></div><div><span style="font-size: 15px; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: pre-line; background-color: rgb(255, 255, 255);"><a href="https://github.com/setchi/FancyScrollView" style="font-size: 15px; font-family: -apple-system, BlinkMacSystemFont, &quot;Helvetica Neue&quot;, Helvetica, Arial, &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">https://github.com/setchi/FancyScrollView</a></span></div><div><br/></div><div>小游戏一体化框架 <a href="https://gitee.com/kwehfwje/game.git">https://gitee.com/kwehfwje/game.git</a></div></span>
</div>
<hr>
<a name="771"/>

<div>
<span><div>踩坑记录</div><div>射线检测的3d物体需要MeshRender</div><div>ui预制体打开时会自带一个Canvas,除非预制体里没有任何一个ui元素;这样手动加ui元素时会在预制体下添加canvas</div><div><img src="Evernote_files/Image [113].png" type="image/png" data-filename="Image.png"/></div><div><br/></div></span>
</div>
<hr>
<a name="775"/>

<div>
<span><div>Shader 文章</div><div><a href="https://zhuanlan.zhihu.com/p/69906067">https://zhuanlan.zhihu.com/p/69906067</a></div><div><a href="https://zhuanlan.zhihu.com/p/668171272">https://zhuanlan.zhihu.com/p/668171272</a></div><div><a href="https://www.zhihu.com/column/c_1213101657103556608">https://www.zhihu.com/column/c_1213101657103556608</a></div><div><br/></div></span>
</div>
<hr>
<a name="776"/>

<div>
<span><div>lineRender 相关</div><div>问题:位置的角度太大,画出的线会扭曲;</div><div>解决方式1:每个位置一个lineRender</div><div>解决方式2:每个点多加两个相同的点(不知道为啥)</div><div><img src="Evernote_files/Image [114].png" type="image/png" data-filename="Image.png"/></div><div><br/></div></span>
</div>
<hr>
<a name="781"/>

<div>
<span><div><div><div><h1 style="box-sizing: border-box; outline: 0px; margin: 0px; padding: 0px; font-size: 28px; overflow-wrap: break-word; word-break: break-all; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255);"><span style="box-sizing: border-box; outline: 0px; font-size: 28px; overflow-wrap: break-word; word-break: break-all; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; color: rgb(34, 34, 38); font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, SimHei, Arial, SimSun; font-variant-caps: normal; font-variant-ligatures: common-ligatures; font-weight: bold;">Win10中使用docker安装nginx随笔</span></h1><div>参考文章:<a href="https://blog.csdn.net/mzl87/article/details/132148356?fromshare=blogdetail&amp;sharetype=blogdetail&amp;sharerId=132148356&amp;sharerefer=PC&amp;sharesource=weixin_40940812&amp;sharefrom=from_link">https://blog.csdn.net/mzl87/article/details/132148356?fromshare=blogdetail&amp;sharetype=blogdetail&amp;sharerId=132148356&amp;sharerefer=PC&amp;sharesource=weixin_40940812&amp;sharefrom=from_link</a></div><div>需要提前创建文件夹,将镜像的配置复制到本地</div><div style="box-sizing: border-box; padding: 8px; font-family: Monaco, Menlo, Consolas, &quot;Courier New&quot;, monospace; font-size: 12px; color: rgb(51, 51, 51); border-radius: 4px; background-color: rgb(251, 250, 248); border: 1px solid rgba(0, 0, 0, 0.15);-en-codeblock:true;"><div>docker cp nginx:/etc/nginx/nginx.conf E:/nginx/nginx.conf</div><div>docker cp nginx:/etc/nginx/conf.d E:/nginx/conf.d</div><div>docker cp nginx:/usr/share/nginx/html E:/nginx/</div></div><div><img src="Evernote_files/Image [115].png" type="image/png" data-filename="Image.png"/></div><div>然后在控制台上输入指令</div></div><div style="box-sizing: border-box; padding: 8px; font-family: Monaco, Menlo, Consolas, &quot;Courier New&quot;, monospace; font-size: 12px; color: rgb(51, 51, 51); border-radius: 4px; background-color: rgb(251, 250, 248); border: 1px solid rgba(0, 0, 0, 0.15);-en-codeblock:true;"><div># 清理旧容器（可选）</div><div>docker stop mynginx</div><div>docker rm mynginx</div><div><br/></div><div><br/></div><div># 启动新容器</div><div>docker run -d --privileged=true --restart=always `</div><div>  -p 9091:80 `</div><div>  -v E:/nginx/nginx.conf:/etc/nginx/nginx.conf `</div><div>  -v E:/nginx/conf.d/default.conf:/etc/nginx/conf.d/default.conf `</div><div>  -v E:/nginx/html:/usr/share/nginx/html `</div><div>  -v E:/nginx/log:/var/log/nginx `</div><div>  --name mynginx nginx:latest</div></div><div>nginx服务的配置和部署参考视频:【Docker安装和配置nginx服务】 <a href="https://www.bilibili.com/video/BV1SE411x7hw/?p=5&amp;share_source=copy_web&amp;vd_source=e730e98e79aa537aeb9b71e050e79bde">https://www.bilibili.com/video/BV1SE411x7hw/?p=5&amp;share_source=copy_web&amp;vd_source=e730e98e79aa537aeb9b71e050e79bde</a></div><ol><li><div>html文件夹创建不同域名访问时指向的文件夹<img src="Evernote_files/Image [116].png" type="image/png" data-filename="Image.png"/></div></li><li><div>宿主机host将域名和ip地址对应</div></li><ol><li><div><a href="http://www.colin.com/">www.colin.com</a> 对应127.0.0.1</div></li><li><div><a href="http://blog.colin.com/">blog.colin.com</a> 对应127.0.0.1</div></li></ol><li><div>在nginx.conf里<span style="font-size: unset; color: unset; font-family: unset;">添加server配置</span></div></li></ol><div style="box-sizing: border-box; padding: 8px; font-family: Monaco, Menlo, Consolas, &quot;Courier New&quot;, monospace; font-size: 12px; color: rgb(51, 51, 51); border-radius: 4px; background-color: rgb(251, 250, 248); border: 1px solid rgba(0, 0, 0, 0.15);-en-codeblock:true;"><div>nginx.conf 末尾追加</div><div>#配置域名www.colin.com</div><div>    server{</div><div>        listen       80;</div><div>        server_name  www.colin.com;</div><div><br/></div><div><br/></div><div>        location / {</div><div>            root   /usr/share/nginx/html/www.colin.com;</div><div>            index  index.html index.htm;</div><div>        }</div><div>    }</div><div>    #配置域名blog.colin.com</div><div>    server{</div><div>        listen       80;</div><div>        server_name  blog.colin.com;</div><div><br/></div><div><br/></div><div>        location / {</div><div>            root   /usr/share/nginx/html/blog.colin.com;</div><div>            index  index.html index.htm;</div><div>        }</div><div>    }</div></div><div><br/></div></div><div>https反向代理</div><div>参考视频: <a href="https://www.bilibili.com/video/BV1uH4y1w7je/?spm_id_from=333.337.search-card.all.click&amp;vd_source=50488da08692177c9ffc8029274746f4">Nginx实战 - 配置HTTPS | 数字证书和私钥 | Docker Compose容器_哔哩哔哩_bilibili</a></div><ol><li><div>在阿里云申请免费测试证书</div></li><li><div>创建文件夹存放ssl证书文件和私钥文件</div></li><li><div>docker命令行添加https的端口映射</div></li><li><div>在nginx中配置反向代理</div></li></ol><div><br/></div></div></span>
</div>
<hr>
<a name="789"/>

<div>
<span><div><div><span style="color: unset; font-family: unset; font-size: 18pt;">项目接入luban导表工具</span><br/></div><div>--步骤结合视频【Unity Luban基础使用1】 <a href="https://www.bilibili.com/video/BV1oyY2eNEWi/?share_source=copy_web&amp;vd_source=e730e98e79aa537aeb9b71e050e79bde">https://www.bilibili.com/video/BV1oyY2eNEWi/?share_source=copy_web&amp;vd_source=e730e98e79aa537aeb9b71e050e79bde</a>以及 luban官方文档实践总结</div><ol><li><div>配置.net 8.0;并且下载<a href="https://gitee.com/focus-creative-games/luban_examples">https://gitee.com/focus-creative-games/luban_examples</a> 示例项目</div></li><li><div>unity添加 luban包, <span style="font-size: 15.2px; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(246, 247, 248);"><a href="https://gitee.com/focus-creative-games/luban_unity.git" style="background-color: rgb(246, 247, 248); font-size: 15.2px; font-family: SFMono-Regular, Menlo, Monaco, Consolas, &quot;Liberation Mono&quot;, &quot;Courier New&quot;, monospace; font-variant-caps: normal; font-variant-ligatures: normal;">https://gitee.com/focus-creative-games/luban_unity.git</a></span></div></li><li><div><span style="font-size: 16px; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; color: rgb(28, 30, 33); font-family: system-ui, -apple-system, &quot;Segoe UI&quot;, Roboto, Ubuntu, Cantarell, &quot;Noto Sans&quot;, sans-serif, BlinkMacSystemFont, &quot;Segoe UI&quot;, Helvetica, Arial, sans-serif, &quot;Apple Color Emoji&quot;, &quot;Segoe UI Emoji&quot;, &quot;Segoe UI Symbol&quot;; font-variant-caps: normal; font-variant-ligatures: normal;">将</span><span style="box-sizing: border-box; vertical-align: middle; background-color: rgb(246, 247, 248); border: 0.1rem solid rgba(0, 0, 0, 0.1); border-radius: 6.4px; font-size: 15.2px; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; color: rgb(28, 30, 33); font-family: SFMono-Regular, Menlo, Monaco, Consolas, &quot;Liberation Mono&quot;, &quot;Courier New&quot;, monospace; font-variant-caps: normal; font-variant-ligatures: normal;">luban_examples/Tools/Luban</span><span style="font-size: 16px; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; color: rgb(28, 30, 33); font-family: system-ui, -apple-system, &quot;Segoe UI&quot;, Roboto, Ubuntu, Cantarell, &quot;Noto Sans&quot;, sans-serif, BlinkMacSystemFont, &quot;Segoe UI&quot;, Helvetica, Arial, sans-serif, &quot;Apple Color Emoji&quot;, &quot;Segoe UI Emoji&quot;, &quot;Segoe UI Symbol&quot;; font-variant-caps: normal; font-variant-ligatures: normal;">复制到任意合适的目录; 下文</span><span style="font-size: 12pt; color: rgb(28, 30, 33); font-family: system-ui;">LUBAN_DLL=%WORKSPACE%\Tools\Luban\Luban.dll需要用到</span></div></li><li><div><span style="font-size: 16px; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; color: rgb(28, 30, 33); font-family: system-ui, -apple-system, &quot;Segoe UI&quot;, Roboto, Ubuntu, Cantarell, &quot;Noto Sans&quot;, sans-serif, BlinkMacSystemFont, &quot;Segoe UI&quot;, Helvetica, Arial, sans-serif, &quot;Apple Color Emoji&quot;, &quot;Segoe UI Emoji&quot;, &quot;Segoe UI Symbol&quot;; font-variant-caps: normal; font-variant-ligatures: normal;">将</span><span style="box-sizing: border-box; vertical-align: middle; background-color: rgb(246, 247, 248); border: 0.1rem solid rgba(0, 0, 0, 0.1); border-radius: 6.4px; font-size: 15.2px; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; color: rgb(28, 30, 33); font-family: SFMono-Regular, Menlo, Monaco, Consolas, &quot;Liberation Mono&quot;, &quot;Courier New&quot;, monospace; font-variant-caps: normal; font-variant-ligatures: normal;">luban_examples/MiniTemplate</span><span style="font-size: 16px; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; color: rgb(28, 30, 33); font-family: system-ui, -apple-system, &quot;Segoe UI&quot;, Roboto, Ubuntu, Cantarell, &quot;Noto Sans&quot;, sans-serif, BlinkMacSystemFont, &quot;Segoe UI&quot;, Helvetica, Arial, sans-serif, &quot;Apple Color Emoji&quot;, &quot;Segoe UI Emoji&quot;, &quot;Segoe UI Symbol&quot;; font-variant-caps: normal; font-variant-ligatures: normal;">复制到项目的合适位置，如</span><span style="box-sizing: border-box; vertical-align: middle; background-color: rgb(246, 247, 248); border: 0.1rem solid rgba(0, 0, 0, 0.1); border-radius: 6.4px; font-size: 15.2px; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; color: rgb(28, 30, 33); font-family: SFMono-Regular, Menlo, Monaco, Consolas, &quot;Liberation Mono&quot;, &quot;Courier New&quot;, monospace; font-variant-caps: normal; font-variant-ligatures: normal;">{proj}</span><span style="font-size: 16px; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; color: rgb(28, 30, 33); font-family: system-ui, -apple-system, &quot;Segoe UI&quot;, Roboto, Ubuntu, Cantarell, &quot;Noto Sans&quot;, sans-serif, BlinkMacSystemFont, &quot;Segoe UI&quot;, Helvetica, Arial, sans-serif, &quot;Apple Color Emoji&quot;, &quot;Segoe UI Emoji&quot;, &quot;Segoe UI Symbol&quot;; font-variant-caps: normal; font-variant-ligatures: normal;">。建议将MiniTemplate改名为DataTables或者别的名字，MiniTemplates下的子目录建议保持原名。</span></div></li><li><div><span style="font-size: 11pt; color: rgb(28, 30, 33); font-family: SFMono-Regular;">配置解析表格路径</span></div></li><li><div><span style="font-size: 11pt; color: rgb(28, 30, 33); font-family: SFMono-Regular;">需要生成表时只需要执行gen.bat文件</span></div></li><li><div><span style="font-size: 11pt; color: rgb(28, 30, 33); font-family: SFMono-Regular;">生成前的准备,</span></div></li><ul><li><div><span style="font-size: 11pt; color: rgb(28, 30, 33); font-family: SFMono-Regular;">手动注册表名字 在_tables_.xlsx中注册,full_name需要加上前缀Tb;在子目录sth内的表写成sth.Tbxxx</span><span style="font-size: 11pt; color: rgb(28, 30, 33); font-family: SFMono-Regular;"><img src="Evernote_files/Image [117].png" type="image/png" data-filename="Image.png"/></span></div></li><li><div>自动注册表,以#开头包含子目录</div></li></ul></ol><div style="box-sizing: border-box; padding: 8px; font-family: Monaco, Menlo, Consolas, &quot;Courier New&quot;, monospace; font-size: 12px; color: rgb(51, 51, 51); border-radius: 4px; background-color: rgb(251, 250, 248); border: 1px solid rgba(0, 0, 0, 0.15);-en-codeblock:true;"><div>REM当前批处理文件所在目录</div><div>set BAT_DIR=%~dp0</div><div>REM 项目根目录</div><div>set WORKSPACE=%BAT_DIR%..</div><div>set LUBAN_DLL=%WORKSPACE%\Tools\Luban\Luban.dll</div><div>set CONF_ROOT=.</div><div><br/></div><div><br/></div><div>dotnet %LUBAN_DLL% ^</div><div>    -t client ^</div><div>    -c cs-simple-json ^</div><div>    -d json  ^</div><div>    --conf %CONF_ROOT%\luban.conf ^</div><div>    -x outputCodeDir=%WORKSPACE%\Assets\Script\Tables ^</div><div>    -x outputDataDir=%WORKSPACE%\Assets\GenerateDatas\json</div><div><br/></div><div><br/></div><div>pause</div></div><div><br/></div><div><br/></div><div><br/></div><div>luban 数据在表格中的写法<img src="Evernote_files/Image [118].png" type="image/png" data-filename="Image.png"/></div><div><br/></div><div><span style="font-size: 16px; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: pre-line; color: rgb(24, 25, 28); font-family: -apple-system, BlinkMacSystemFont, &quot;Helvetica Neue&quot;, Helvetica, Arial, &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">Luban中自定义枚举及自定义类 :</span></div><div><a href="https://www.bilibili.com/video/BV1vEWKetE7f?spm_id_from=333.788.recommend_more_video.-1&amp;vd_source=50488da08692177c9ffc8029274746f4">Luban基础使用2_哔哩哔哩_bilibili</a></div><div><br/></div></div><div><br/></div></span>
</div>
<hr>
<a name="795"/>

<div>
<span><div>项目版本控制</div><div><a href="https://zhuanlan.zhihu.com/p/32459779034">在Unity中使用Git进行版本控制：从避坑到高效协作的完整指南 - 知乎</a></div><div><br/></div><div>gitignore内容解释 </div><div><a href="Evernote_files/.gitignore"><img src="Evernote_files/d0e62156a36942ae396ca04c8d9c6fd5.png" alt=".gitignore"></a></div><div style="box-sizing: border-box; padding: 8px; font-family: Monaco, Menlo, Consolas, &quot;Courier New&quot;, monospace; font-size: 12px; color: rgb(51, 51, 51); border-radius: 4px; background-color: rgb(251, 250, 248); border: 1px solid rgba(0, 0, 0, 0.15);-en-codeblock:true;"><div>核心目录排除</div><div>1.</div><div>/[Ll]ibrary/</div><div>Unity 自动生成的本地缓存目录，包含临时资源、脚本编译结果等。不同操作系统可能大小写不一致，故同时匹配 Library 和 library。</div><div>2.</div><div>/[Tt]emp/</div><div>编译和打包时的临时目录，每次打开项目会重新生成，无需版本控制。</div><div>3.</div><div>/[Oo]bj/</div><div>代码编译过程中生成的中间文件（如 C# 的 .obj 文件），可安全忽略。</div><div>4.</div><div>/[Bb]uild/ 和 /[Bb]uilds/</div><div>存放编译后的可执行文件（如 APK、EXE），这些是生成产物，而非源码。</div><div>5.</div><div>/[Ll]ogs/</div><div>Unity 编辑器或编译过程的日志文件，通常用于调试，无需提交。</div><div>6.</div><div>/[Uu]user[Ss]ettings/</div><div>用户个性化设置（如编辑器布局、快捷键），避免覆盖团队成员的配置。</div><div><br/></div><div><br/></div><div>敏感或大型文件</div><div>7.</div><div>/[Mm]emoryCaptures/</div><div>内存快照文件（用于性能分析），体积巨大且可能包含敏感数据。</div><div>8.</div><div>sysinfo.txt</div><div>Unity 崩溃时生成的系统信息报告，包含硬件和软件环境信息。</div><div><br/></div><div><br/></div><div>资源与元数据规则</div><div>9.</div><div>!/[Aa]ssets/**/*.meta</div><div>例外规则：强制跟踪所有 Assets/ 下的 .meta 文件。</div><div>Unity 用 .meta 文件记录资源（如贴图、脚本）的 GUID 和导入设置，必须提交以保持引用关系。</div><div><br/></div><div><br/></div><div>IDE 和工具相关</div><div>10.</div><div>.vs/</div><div>Visual Studio 的缓存目录（如 IntelliSense 数据库）。</div><div>11.</div><div>.gradle/</div><div>Android 构建时 Gradle 的本地缓存，自动生成且体积大。</div><div>12.</div><div>/[Aa]ssets/Plugins/Editor/JetBrains*</div><div>JetBrains Rider 插件自动生成的文件，通常无需提交。</div><div>13.</div><div>*.csproj, *.sln, *.userprefs 等</div><div>排除 Visual Studio/MonoDevelop 的项目文件（Unity 会自动生成）。</div><div><br/></div><div><br/></div><div>构建产物</div><div>14.</div><div>*.apk, *.aab, *.unitypackage</div><div>安卓应用包或 Unity 资源包，属于生成结果而非源码。</div><div>15.</div><div>crashlytics-build.properties</div><div>Firebase Crashlytics 的自动生成文件，包含敏感构建信息。</div><div><br/></div><div><br/></div><div>高级功能相关</div><div>16.</div><div>/[Aa]ssets/[Aa]ddressable[Aa]ssets[Dd]ata/*/*.bin*</div><div>Addressables 系统生成的资源包，本地缓存无需提交。</div><div>17.</div><div>/[Aa]ssets/[Ss]treamingAssets/aa/*</div><div>临时自动生成的 Addressables 资源，重新构建时会覆盖。</div><div><br/></div><div><br/></div><div>注意事项</div><div>* /[Aa]ssets/AssetStoreTools* 默认被注释，如需忽略 Unity Asset Store 的上传工具插件，可取消注释。</div><div>* 若使用其他 IDE（如 VSCode），可能需要补充忽略 .vscode/ 目录。</div><div>* 保持 .gitignore 更新，参考 GitHub 官方 Unity 模板。</div><div><br/></div><div><br/></div></div><div><br/></div></span>
</div>
<hr>
<a name="799"/>

<div>
<span><div><div><font style="font-size: 16pt;"><b>unity协程转异步</b></font></div><div>## 1. 核心组件</div><div>### 1.1 AsyncCoroutineRunner</div><div>这是一个单例类，负责实际运行和管理协程。它实现了 SingletonForMono&lt;AsyncCoroutineRunner&gt; 和 ISingletonInitialize 接口。</div><div><br/></div><div>### 1.2 CoroutineExtensions_ToAsync</div><div>这个静态类提供了一系列扩展方法，为 Unity 的各种异步操作类型添加 GetAwaiter() 方法，使它们可以被 await 关键字使用。</div><div><br/></div><div>## 2. 工作流程</div><div>### 2.1 初始化流程</div><div>1. 当第一次访问 AsyncCoroutineRunner.Instance 时，会创建一个新的游戏对象并添加 AsyncCoroutineRunner 组件</div><div>2. 在 Awake() 中，会调用 Init() 方法</div><div>3. Init() 方法将游戏对象设置为隐藏状态 ( HideFlags.HideAndDontSave )</div><div>### 2.2 协程转异步流程</div><div>当使用 await 关键字等待一个 Unity 的异步操作时，流程如下：</div><div><br/></div><div>1. 扩展方法调用 ：编译器查找对应类型的 GetAwaiter() 方法，找到 CoroutineExtensions_ToAsync 中定义的扩展方法</div><div>2. 创建 Awaiter ：扩展方法创建一个 CoroutineAwaiter 或 CoroutineAwaiter&lt;T&gt; 对象</div><ul><li><div>实现了 IAwaitable 接口，是协程转异步的核心类;这些类负责管理异步操作的状态、结果和异常，并在操作完成时通知等待者。</div></li></ul><div><br/></div><div>3. 提交到 Runner ：调用 AsyncCoroutineRunner.Instance 的相应方法（如 DealInstruction ）处理异步操作</div><div>4. 启动协程 ： AsyncCoroutineRunner 启动一个协程来监视异步操作的完成</div><div>5. 等待完成 ：协程使用 yield return 等待异步操作完成</div><div>6. 设置结果 ：异步操作完成后，调用 awaiter 的 SetResult 方法，设置结果和可能的异常</div><div>7. 继续执行 ： SetResult 方法会调用 SyncContextUtil.RunOnUnityScheduler(m_continuation) 确保后续代码在 Unity 主线程上执行</div><div>8. 返回结果 ：当 await 表达式求值时，会调用 awaiter 的 GetResult() 方法获取结果或抛出异常</div><div style="box-sizing: border-box; padding: 8px; font-family: Monaco, Menlo, Consolas, &quot;Courier New&quot;, monospace; font-size: 12px; color: rgb(51, 51, 51); border-radius: 4px; background-color: rgb(251, 250, 248); border: 1px solid rgba(0, 0, 0, 0.15);-en-codeblock:true;"><div>┌─────────────────────────────────────────────────────────────────────────┐</div><div>│                           协程转异步流程图                              │</div><div>└─────────────────────────────────────────────────────────────────────────┘</div><div>                                    │</div><div>                                    ▼</div><div>┌─────────────────────────────────────────────────────────────────────────┐</div><div>│                         1. 调用 await 异步操作                          │</div><div>│                                                                         │</div><div>│  例如: GameObject prefab = await Resources.LoadAsync&lt;GameObject&gt;(path); │</div><div>└─────────────────────────────────────────────────────────────────────────┘</div><div>                                    │</div><div>                                    ▼</div><div>┌─────────────────────────────────────────────────────────────────────────┐</div><div>│                      2. 编译器查找 GetAwaiter() 方法                    │</div><div>│                                                                         │</div><div>│  在 CoroutineExtensions_ToAsync 中找到对应类型的扩展方法                │</div><div>└─────────────────────────────────────────────────────────────────────────┘</div><div>                                    │</div><div>                                    ▼</div><div>┌─────────────────────────────────────────────────────────────────────────┐</div><div>│                         3. 创建 Awaiter 对象                           │</div><div>│                                                                         │</div><div>│  创建 CoroutineAwaiter 或 CoroutineAwaiter&lt;T&gt; 实例                     │</div><div>└─────────────────────────────────────────────────────────────────────────┘</div><div>                                    │</div><div>                                    ▼</div><div>┌─────────────────────────────────────────────────────────────────────────┐</div><div>│                     4. 提交到 AsyncCoroutineRunner                      │</div><div>│                                                                         │</div><div>│  调用 AsyncCoroutineRunner.Instance.DealXXXInstruction() 方法          │</div><div>└─────────────────────────────────────────────────────────────────────────┘</div><div>                                    │</div><div>                                    ▼</div><div>┌─────────────────────────────────────────────────────────────────────────┐</div><div>│                           5. 启动监视协程                               │</div><div>│                                                                         │</div><div>│  AsyncCoroutineRunner 启动协程监视异步操作完成情况                     │</div><div>└─────────────────────────────────────────────────────────────────────────┘</div><div>                                    │</div><div>                                    ▼</div><div>┌─────────────────────────────────────────────────────────────────────────┐</div><div>│                      6. 暂停当前方法执行流程                            │</div><div>│                                                                         │</div><div>│  await 表达式暂停当前方法，返回到调用者                                │</div><div>└─────────────────────────────────────────────────────────────────────────┘</div><div>                                    │</div><div>                                    ▼</div><div>┌─────────────────────────────────────────────────────────────────────────┐</div><div>│                       7. 异步操作在后台执行                             │</div><div>│                                                                         │</div><div>│  Unity 继续执行异步操作（如资源加载）                                  │</div><div>└─────────────────────────────────────────────────────────────────────────┘</div><div>                                    │</div><div>                                    ▼</div><div>┌─────────────────────────────────────────────────────────────────────────┐</div><div>│                         8. 异步操作完成                                 │</div><div>│                                                                         │</div><div>│  协程检测到操作完成，调用 awaiter.SetResult() 设置结果                 │</div><div>└─────────────────────────────────────────────────────────────────────────┘</div><div>                                    │</div><div>                                    ▼</div><div>┌─────────────────────────────────────────────────────────────────────────┐</div><div>│                      9. 调度回调到 Unity 主线程                         │</div><div>│                                                                         │</div><div>│  通过 SyncContextUtil.RunOnUnityScheduler 确保在主线程执行             │</div><div>└─────────────────────────────────────────────────────────────────────────┘</div><div>                                    │</div><div>                                    ▼</div><div>┌─────────────────────────────────────────────────────────────────────────┐</div><div>│                        10. 恢复异步方法执行                             │</div><div>│                                                                         │</div><div>│  await 表达式后的代码继续执行                                          │</div><div>└─────────────────────────────────────────────────────────────────────────┘</div><div>                                    │</div><div>                                    ▼</div><div>┌─────────────────────────────────────────────────────────────────────────┐</div><div>│                         11. 获取操作结果                                │</div><div>│                                                                         │</div><div>│  调用 awaiter.GetResult() 获取结果或抛出异常                           │</div><div>└─────────────────────────────────────────────────────────────────────────┘</div><div>                                    │</div><div>                                    ▼</div><div>┌─────────────────────────────────────────────────────────────────────────┐</div><div>│                       12. 异步方法继续执行                              │</div><div>│                                                                         │</div><div>│  使用获取到的结果继续执行后续代码                                      │</div><div>└─────────────────────────────────────────────────────────────────────────┘</div></div><div><br/></div></div></span>
</div>
<hr>
<a name="801"/>

<div>
<span><div><div><span style="font-weight: bold; font-size: 18pt;">洗牌算法</span></div><h3 style="font-size: 18.288px; margin: 18.288px 0px 13.716px; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255);"><span style="font-size: 18.288px; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; color: rgb(64, 64, 64); font-family: DeepSeek-CJK-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Noto Sans&quot;, Ubuntu, Cantarell, &quot;Helvetica Neue&quot;, Oxygen, &quot;Open Sans&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: bold; line-height: 1.5;">1. 原始Fisher-Yates算法（需要新数组）</span></h3><h4 style="font-size: 16.002px; margin: 18.288px 0px 13.716px; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255);"><span style="font-size: 16.002px; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255); color: rgb(64, 64, 64); font-family: DeepSeek-CJK-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Noto Sans&quot;, Ubuntu, Cantarell, &quot;Helvetica Neue&quot;, Oxygen, &quot;Open Sans&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: bold; line-height: 28.575px;">算法步骤</span><span style="font-size: 16.002px; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255); color: rgb(64, 64, 64); font-family: DeepSeek-CJK-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Noto Sans&quot;, Ubuntu, Cantarell, &quot;Helvetica Neue&quot;, Oxygen, &quot;Open Sans&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: bold; line-height: 28.575px;">：</span></h4><ol start="1" style="margin: 13.716px 0px; padding-left: 27.432px; font-size: 16.002px; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255);"><li><div style="margin-top: 0px; margin-right: 0px; margin-left: 0px; font-size: 16.002px; margin-bottom: 0px !important;"><span style="font-size: 16.002px; color: rgb(64, 64, 64); font-family: DeepSeek-CJK-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Noto Sans&quot;, Ubuntu, Cantarell, &quot;Helvetica Neue&quot;, Oxygen, &quot;Open Sans&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; line-height: 28.575px; font-weight: bold;">开辟新数组</span><span style="font-size: 16.002px; color: rgb(64, 64, 64); font-family: DeepSeek-CJK-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Noto Sans&quot;, Ubuntu, Cantarell, &quot;Helvetica Neue&quot;, Oxygen, &quot;Open Sans&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; line-height: 28.575px;">：创建一个空数组作为结果。</span></div></li><li style="margin-top: 4px;"><div style="margin: 0px 0px 4px; font-size: 16.002px;"><span style="font-size: 16.002px; color: rgb(64, 64, 64); font-family: DeepSeek-CJK-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Noto Sans&quot;, Ubuntu, Cantarell, &quot;Helvetica Neue&quot;, Oxygen, &quot;Open Sans&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; line-height: 28.575px; font-weight: bold;">随机抽取并删除</span><span style="font-size: 16.002px; color: rgb(64, 64, 64); font-family: DeepSeek-CJK-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Noto Sans&quot;, Ubuntu, Cantarell, &quot;Helvetica Neue&quot;, Oxygen, &quot;Open Sans&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; line-height: 28.575px;">：</span></div></li><ul style="margin: 4px 0px 0px; padding-left: 27.432px;"><li><div style="margin-top: 0px; margin-right: 0px; margin-left: 0px; font-size: 16.002px; margin-bottom: 0px !important;"><span style="font-size: 16.002px; color: rgb(64, 64, 64); font-family: DeepSeek-CJK-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Noto Sans&quot;, Ubuntu, Cantarell, &quot;Helvetica Neue&quot;, Oxygen, &quot;Open Sans&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; line-height: 28.575px;">从原数组中</span><span style="font-size: 16.002px; color: rgb(64, 64, 64); font-family: DeepSeek-CJK-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Noto Sans&quot;, Ubuntu, Cantarell, &quot;Helvetica Neue&quot;, Oxygen, &quot;Open Sans&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; line-height: 28.575px; font-weight: bold;">随机选择一个元素</span><span style="font-size: 16.002px; color: rgb(64, 64, 64); font-family: DeepSeek-CJK-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Noto Sans&quot;, Ubuntu, Cantarell, &quot;Helvetica Neue&quot;, Oxygen, &quot;Open Sans&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; line-height: 28.575px;">，将其</span><span style="font-size: 16.002px; color: rgb(64, 64, 64); font-family: DeepSeek-CJK-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Noto Sans&quot;, Ubuntu, Cantarell, &quot;Helvetica Neue&quot;, Oxygen, &quot;Open Sans&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; line-height: 28.575px; font-weight: bold;">添加到新数组</span><span style="font-size: 16.002px; color: rgb(64, 64, 64); font-family: DeepSeek-CJK-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Noto Sans&quot;, Ubuntu, Cantarell, &quot;Helvetica Neue&quot;, Oxygen, &quot;Open Sans&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; line-height: 28.575px;">。</span></div></li><li style="margin-top: 4px;"><div style="margin-top: 0px; margin-right: 0px; margin-left: 0px; font-size: 16.002px; margin-bottom: 0px !important;"><span style="font-size: 16.002px; color: rgb(64, 64, 64); font-family: DeepSeek-CJK-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Noto Sans&quot;, Ubuntu, Cantarell, &quot;Helvetica Neue&quot;, Oxygen, &quot;Open Sans&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; line-height: 28.575px; font-weight: bold;">从原数组中删除该元素</span><span style="font-size: 16.002px; color: rgb(64, 64, 64); font-family: DeepSeek-CJK-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Noto Sans&quot;, Ubuntu, Cantarell, &quot;Helvetica Neue&quot;, Oxygen, &quot;Open Sans&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; line-height: 28.575px;">。</span></div></li></ul><li style="margin-top: 4px;"><div style="margin-top: 0px; margin-right: 0px; margin-left: 0px; font-size: 16.002px; margin-bottom: 0px !important;"><span style="font-size: 16.002px; color: rgb(64, 64, 64); font-family: DeepSeek-CJK-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Noto Sans&quot;, Ubuntu, Cantarell, &quot;Helvetica Neue&quot;, Oxygen, &quot;Open Sans&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; line-height: 28.575px; font-weight: bold;">重复</span><span style="font-size: 16.002px; color: rgb(64, 64, 64); font-family: DeepSeek-CJK-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Noto Sans&quot;, Ubuntu, Cantarell, &quot;Helvetica Neue&quot;, Oxygen, &quot;Open Sans&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; line-height: 28.575px;">：直到原数组为空。</span></div></li></ol><h4 style="font-size: 16.002px; margin: 18.288px 0px 13.716px; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255);"><span style="font-size: 16.002px; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255); color: rgb(64, 64, 64); font-family: DeepSeek-CJK-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Noto Sans&quot;, Ubuntu, Cantarell, &quot;Helvetica Neue&quot;, Oxygen, &quot;Open Sans&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: bold; line-height: 28.575px;">时间复杂度</span><span style="font-size: 16.002px; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; color: rgb(64, 64, 64); font-family: DeepSeek-CJK-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Noto Sans&quot;, Ubuntu, Cantarell, &quot;Helvetica Neue&quot;, Oxygen, &quot;Open Sans&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: bold; line-height: 28.575px;">：</span></h4><ul style="margin: 13.716px 0px; padding-left: 27.432px; font-size: 16.002px; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255);"><li><div style="margin-top: 0px; margin-right: 0px; margin-left: 0px; font-size: 16.002px; margin-bottom: 0px !important;"><span style="font-size: 16.002px; color: rgb(64, 64, 64); font-family: DeepSeek-CJK-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Noto Sans&quot;, Ubuntu, Cantarell, &quot;Helvetica Neue&quot;, Oxygen, &quot;Open Sans&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; line-height: 28.575px; font-weight: bold;">每次删除操作的时间代价</span><span style="font-size: 16.002px; color: rgb(64, 64, 64); font-family: DeepSeek-CJK-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Noto Sans&quot;, Ubuntu, Cantarell, &quot;Helvetica Neue&quot;, Oxygen, &quot;Open Sans&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; line-height: 28.575px;">：若原数组是连续存储结构（如Python列表），删除中间元素需要将后续元素前移，时间复杂度为</span><span style="font-size: 16.002px; color: rgb(64, 64, 64); font-family: DeepSeek-CJK-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Noto Sans&quot;, Ubuntu, Cantarell, &quot;Helvetica Neue&quot;, Oxygen, &quot;Open Sans&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; line-height: 28.575px;"> </span><span style="font-size: 16.002px; color: rgb(64, 64, 64); font-family: DeepSeek-CJK-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Noto Sans&quot;, Ubuntu, Cantarell, &quot;Helvetica Neue&quot;, Oxygen, &quot;Open Sans&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; line-height: 28.575px; font-weight: bold;">O(n)</span><span style="font-size: 16.002px; color: rgb(64, 64, 64); font-family: DeepSeek-CJK-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Noto Sans&quot;, Ubuntu, Cantarell, &quot;Helvetica Neue&quot;, Oxygen, &quot;Open Sans&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; line-height: 28.575px;">。</span></div></li><li style="margin-top: 4px;"><div style="margin-top: 0px; margin-right: 0px; margin-left: 0px; font-size: 16.002px; margin-bottom: 0px !important;"><span style="font-size: 16.002px; color: rgb(64, 64, 64); font-family: DeepSeek-CJK-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Noto Sans&quot;, Ubuntu, Cantarell, &quot;Helvetica Neue&quot;, Oxygen, &quot;Open Sans&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; line-height: 28.575px; font-weight: bold;">总时间复杂度</span><span style="font-size: 16.002px; color: rgb(64, 64, 64); font-family: DeepSeek-CJK-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Noto Sans&quot;, Ubuntu, Cantarell, &quot;Helvetica Neue&quot;, Oxygen, &quot;Open Sans&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; line-height: 28.575px;">：共需删除</span><span style="font-size: 16.002px; color: rgb(64, 64, 64); font-family: DeepSeek-CJK-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Noto Sans&quot;, Ubuntu, Cantarell, &quot;Helvetica Neue&quot;, Oxygen, &quot;Open Sans&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; line-height: 28.575px;"> </span><span style="font-size: 0.875em; background-color: rgb(236, 236, 236); border-radius: 4px; color: rgb(64, 64, 64); font-family: Menlo, &quot;Roboto Mono&quot;, &quot;Courier New&quot;, Courier, monospace, Inter, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; line-height: 28.575px; font-weight: bold;">n</span><span style="font-size: 16.002px; color: rgb(64, 64, 64); font-family: DeepSeek-CJK-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Noto Sans&quot;, Ubuntu, Cantarell, &quot;Helvetica Neue&quot;, Oxygen, &quot;Open Sans&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; line-height: 28.575px;"> </span><span style="font-size: 16.002px; color: rgb(64, 64, 64); font-family: DeepSeek-CJK-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Noto Sans&quot;, Ubuntu, Cantarell, &quot;Helvetica Neue&quot;, Oxygen, &quot;Open Sans&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; line-height: 28.575px;">次，每次删除平均需要移动</span><span style="font-size: 16.002px; color: rgb(64, 64, 64); font-family: DeepSeek-CJK-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Noto Sans&quot;, Ubuntu, Cantarell, &quot;Helvetica Neue&quot;, Oxygen, &quot;Open Sans&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; line-height: 28.575px;"> </span><span style="font-size: 0.875em; background-color: rgb(236, 236, 236); border-radius: 4px; color: rgb(64, 64, 64); font-family: Menlo, &quot;Roboto Mono&quot;, &quot;Courier New&quot;, Courier, monospace, Inter, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; line-height: 28.575px; font-weight: bold;">n/2</span><span style="font-size: 16.002px; color: rgb(64, 64, 64); font-family: DeepSeek-CJK-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Noto Sans&quot;, Ubuntu, Cantarell, &quot;Helvetica Neue&quot;, Oxygen, &quot;Open Sans&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; line-height: 28.575px;"> </span><span style="font-size: 16.002px; color: rgb(64, 64, 64); font-family: DeepSeek-CJK-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Noto Sans&quot;, Ubuntu, Cantarell, &quot;Helvetica Neue&quot;, Oxygen, &quot;Open Sans&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; line-height: 28.575px;">个元素，因此总时间为</span><span style="font-size: 16.002px; color: rgb(64, 64, 64); font-family: DeepSeek-CJK-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Noto Sans&quot;, Ubuntu, Cantarell, &quot;Helvetica Neue&quot;, Oxygen, &quot;Open Sans&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; line-height: 28.575px;"> </span><span style="font-size: 16.002px; color: rgb(64, 64, 64); font-family: DeepSeek-CJK-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Noto Sans&quot;, Ubuntu, Cantarell, &quot;Helvetica Neue&quot;, Oxygen, &quot;Open Sans&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; line-height: 28.575px; font-weight: bold;">O(n²)</span><span style="font-size: 16.002px; color: rgb(64, 64, 64); font-family: DeepSeek-CJK-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Noto Sans&quot;, Ubuntu, Cantarell, &quot;Helvetica Neue&quot;, Oxygen, &quot;Open Sans&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; line-height: 28.575px;">。</span></div></li></ul><h4 style="font-size: 16.002px; margin: 18.288px 0px 13.716px; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255);"><span style="font-size: 16.002px; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255); color: rgb(64, 64, 64); font-family: DeepSeek-CJK-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Noto Sans&quot;, Ubuntu, Cantarell, &quot;Helvetica Neue&quot;, Oxygen, &quot;Open Sans&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: bold; line-height: 28.575px;">空间复杂度</span><span style="font-size: 16.002px; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255); color: rgb(64, 64, 64); font-family: DeepSeek-CJK-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Noto Sans&quot;, Ubuntu, Cantarell, &quot;Helvetica Neue&quot;, Oxygen, &quot;Open Sans&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: bold; line-height: 28.575px;">：</span></h4><ul style="margin: 13.716px 0px; padding-left: 27.432px; font-size: 16.002px; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255);"><li><div style="margin-top: 0px; margin-right: 0px; margin-left: 0px; font-size: 16.002px; margin-bottom: 0px !important;"><span style="font-size: 16.002px; color: rgb(64, 64, 64); font-family: DeepSeek-CJK-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Noto Sans&quot;, Ubuntu, Cantarell, &quot;Helvetica Neue&quot;, Oxygen, &quot;Open Sans&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; line-height: 28.575px;">需要额外的新数组存储结果，空间复杂度为</span><span style="font-size: 16.002px; color: rgb(64, 64, 64); font-family: DeepSeek-CJK-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Noto Sans&quot;, Ubuntu, Cantarell, &quot;Helvetica Neue&quot;, Oxygen, &quot;Open Sans&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; line-height: 28.575px;"> </span><span style="font-size: 16.002px; color: rgb(64, 64, 64); font-family: DeepSeek-CJK-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Noto Sans&quot;, Ubuntu, Cantarell, &quot;Helvetica Neue&quot;, Oxygen, &quot;Open Sans&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; line-height: 28.575px; font-weight: bold;">O(n)</span><span style="font-size: 16.002px; color: rgb(64, 64, 64); font-family: DeepSeek-CJK-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Noto Sans&quot;, Ubuntu, Cantarell, &quot;Helvetica Neue&quot;, Oxygen, &quot;Open Sans&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; line-height: 28.575px;">。</span></div></li></ul><div style="margin-top: 0px; margin-right: 0px; margin-left: 0px; font-size: 16.002px; line-height: 28.575px; margin-bottom: 0px !important;"></div><h3 style="font-size: 18.288px; margin: 18.288px 0px 13.716px; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255);"><span style="font-size: 18.288px; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255); color: rgb(64, 64, 64); font-family: DeepSeek-CJK-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Noto Sans&quot;, Ubuntu, Cantarell, &quot;Helvetica Neue&quot;, Oxygen, &quot;Open Sans&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: bold; line-height: 1.5;">2. 改进的Knuth洗牌算法（原地交换）</span></h3><h4 style="font-size: 16.002px; margin: 18.288px 0px 13.716px; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255);"><span style="font-size: 16.002px; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; color: rgb(64, 64, 64); font-family: DeepSeek-CJK-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Noto Sans&quot;, Ubuntu, Cantarell, &quot;Helvetica Neue&quot;, Oxygen, &quot;Open Sans&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: bold; line-height: 28.575px;">算法步骤</span><span style="font-size: 16.002px; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; color: rgb(64, 64, 64); font-family: DeepSeek-CJK-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Noto Sans&quot;, Ubuntu, Cantarell, &quot;Helvetica Neue&quot;, Oxygen, &quot;Open Sans&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: bold; line-height: 28.575px;">：</span></h4><ol start="1" style="margin: 13.716px 0px; padding-left: 27.432px; font-size: 16.002px; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255);"><li><div style="margin-top: 0px; margin-right: 0px; margin-left: 0px; font-size: 16.002px; margin-bottom: 0px !important;"><span style="font-size: 16.002px; color: rgb(64, 64, 64); font-family: DeepSeek-CJK-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Noto Sans&quot;, Ubuntu, Cantarell, &quot;Helvetica Neue&quot;, Oxygen, &quot;Open Sans&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; line-height: 28.575px; font-weight: bold;">从后向前遍历</span><span style="font-size: 16.002px; color: rgb(64, 64, 64); font-family: DeepSeek-CJK-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Noto Sans&quot;, Ubuntu, Cantarell, &quot;Helvetica Neue&quot;, Oxygen, &quot;Open Sans&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; line-height: 28.575px;">：从最后一个元素开始（索引</span><span style="font-size: 16.002px; color: rgb(64, 64, 64); font-family: DeepSeek-CJK-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Noto Sans&quot;, Ubuntu, Cantarell, &quot;Helvetica Neue&quot;, Oxygen, &quot;Open Sans&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; line-height: 28.575px;"> </span><span style="font-size: 0.875em; background-color: rgb(236, 236, 236); border-radius: 4px; color: rgb(64, 64, 64); font-family: Menlo, &quot;Roboto Mono&quot;, &quot;Courier New&quot;, Courier, monospace, Inter, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; line-height: 28.575px; font-weight: bold;">n-1</span><span style="font-size: 16.002px; color: rgb(64, 64, 64); font-family: DeepSeek-CJK-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Noto Sans&quot;, Ubuntu, Cantarell, &quot;Helvetica Neue&quot;, Oxygen, &quot;Open Sans&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; line-height: 28.575px;">）。</span></div></li><li style="margin-top: 4px;"><div style="margin-top: 0px; margin-right: 0px; margin-left: 0px; font-size: 16.002px; margin-bottom: 0px !important;"><span style="font-size: 16.002px; color: rgb(64, 64, 64); font-family: DeepSeek-CJK-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Noto Sans&quot;, Ubuntu, Cantarell, &quot;Helvetica Neue&quot;, Oxygen, &quot;Open Sans&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; line-height: 28.575px; font-weight: bold;">随机交换</span><span style="font-size: 16.002px; color: rgb(64, 64, 64); font-family: DeepSeek-CJK-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Noto Sans&quot;, Ubuntu, Cantarell, &quot;Helvetica Neue&quot;, Oxygen, &quot;Open Sans&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; line-height: 28.575px;">：在</span><span style="font-size: 16.002px; color: rgb(64, 64, 64); font-family: DeepSeek-CJK-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Noto Sans&quot;, Ubuntu, Cantarell, &quot;Helvetica Neue&quot;, Oxygen, &quot;Open Sans&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; line-height: 28.575px;"> </span><span style="font-size: 0.875em; background-color: rgb(236, 236, 236); border-radius: 4px; color: rgb(64, 64, 64); font-family: Menlo, &quot;Roboto Mono&quot;, &quot;Courier New&quot;, Courier, monospace, Inter, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; line-height: 28.575px; font-weight: bold;">0</span><span style="font-size: 16.002px; color: rgb(64, 64, 64); font-family: DeepSeek-CJK-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Noto Sans&quot;, Ubuntu, Cantarell, &quot;Helvetica Neue&quot;, Oxygen, &quot;Open Sans&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; line-height: 28.575px;"> </span><span style="font-size: 16.002px; color: rgb(64, 64, 64); font-family: DeepSeek-CJK-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Noto Sans&quot;, Ubuntu, Cantarell, &quot;Helvetica Neue&quot;, Oxygen, &quot;Open Sans&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; line-height: 28.575px;">到当前索引</span><span style="font-size: 16.002px; color: rgb(64, 64, 64); font-family: DeepSeek-CJK-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Noto Sans&quot;, Ubuntu, Cantarell, &quot;Helvetica Neue&quot;, Oxygen, &quot;Open Sans&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; line-height: 28.575px;"> </span><span style="font-size: 0.875em; background-color: rgb(236, 236, 236); border-radius: 4px; color: rgb(64, 64, 64); font-family: Menlo, &quot;Roboto Mono&quot;, &quot;Courier New&quot;, Courier, monospace, Inter, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; line-height: 28.575px; font-weight: bold;">i</span><span style="font-size: 16.002px; color: rgb(64, 64, 64); font-family: DeepSeek-CJK-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Noto Sans&quot;, Ubuntu, Cantarell, &quot;Helvetica Neue&quot;, Oxygen, &quot;Open Sans&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; line-height: 28.575px;"> </span><span style="font-size: 16.002px; color: rgb(64, 64, 64); font-family: DeepSeek-CJK-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Noto Sans&quot;, Ubuntu, Cantarell, &quot;Helvetica Neue&quot;, Oxygen, &quot;Open Sans&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; line-height: 28.575px;">之间随机选择一个索引</span><span style="font-size: 16.002px; color: rgb(64, 64, 64); font-family: DeepSeek-CJK-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Noto Sans&quot;, Ubuntu, Cantarell, &quot;Helvetica Neue&quot;, Oxygen, &quot;Open Sans&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; line-height: 28.575px;"> </span><span style="font-size: 0.875em; background-color: rgb(236, 236, 236); border-radius: 4px; color: rgb(64, 64, 64); font-family: Menlo, &quot;Roboto Mono&quot;, &quot;Courier New&quot;, Courier, monospace, Inter, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; line-height: 28.575px; font-weight: bold;">j</span><span style="font-size: 16.002px; color: rgb(64, 64, 64); font-family: DeepSeek-CJK-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Noto Sans&quot;, Ubuntu, Cantarell, &quot;Helvetica Neue&quot;, Oxygen, &quot;Open Sans&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; line-height: 28.575px;">，交换</span><span style="font-size: 16.002px; color: rgb(64, 64, 64); font-family: DeepSeek-CJK-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Noto Sans&quot;, Ubuntu, Cantarell, &quot;Helvetica Neue&quot;, Oxygen, &quot;Open Sans&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; line-height: 28.575px;"> </span><span style="font-size: 0.875em; background-color: rgb(236, 236, 236); border-radius: 4px; color: rgb(64, 64, 64); font-family: Menlo, &quot;Roboto Mono&quot;, &quot;Courier New&quot;, Courier, monospace, Inter, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; line-height: 28.575px; font-weight: bold;">arr[i]</span><span style="font-size: 16.002px; color: rgb(64, 64, 64); font-family: DeepSeek-CJK-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Noto Sans&quot;, Ubuntu, Cantarell, &quot;Helvetica Neue&quot;, Oxygen, &quot;Open Sans&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; line-height: 28.575px;"> </span><span style="font-size: 16.002px; color: rgb(64, 64, 64); font-family: DeepSeek-CJK-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Noto Sans&quot;, Ubuntu, Cantarell, &quot;Helvetica Neue&quot;, Oxygen, &quot;Open Sans&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; line-height: 28.575px;">和</span><span style="font-size: 16.002px; color: rgb(64, 64, 64); font-family: DeepSeek-CJK-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Noto Sans&quot;, Ubuntu, Cantarell, &quot;Helvetica Neue&quot;, Oxygen, &quot;Open Sans&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; line-height: 28.575px;"> </span><span style="font-size: 0.875em; background-color: rgb(236, 236, 236); border-radius: 4px; color: rgb(64, 64, 64); font-family: Menlo, &quot;Roboto Mono&quot;, &quot;Courier New&quot;, Courier, monospace, Inter, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; line-height: 28.575px; font-weight: bold;">arr[j]</span><span style="font-size: 16.002px; color: rgb(64, 64, 64); font-family: DeepSeek-CJK-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Noto Sans&quot;, Ubuntu, Cantarell, &quot;Helvetica Neue&quot;, Oxygen, &quot;Open Sans&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; line-height: 28.575px;">。</span></div></li><li style="margin-top: 4px;"><div style="margin-top: 0px; margin-right: 0px; margin-left: 0px; font-size: 16.002px; margin-bottom: 0px !important;"><span style="font-size: 16.002px; color: rgb(64, 64, 64); font-family: DeepSeek-CJK-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Noto Sans&quot;, Ubuntu, Cantarell, &quot;Helvetica Neue&quot;, Oxygen, &quot;Open Sans&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; line-height: 28.575px; font-weight: bold;">向前移动</span><span style="font-size: 16.002px; color: rgb(64, 64, 64); font-family: DeepSeek-CJK-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Noto Sans&quot;, Ubuntu, Cantarell, &quot;Helvetica Neue&quot;, Oxygen, &quot;Open Sans&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; line-height: 28.575px;">：索引</span><span style="font-size: 16.002px; color: rgb(64, 64, 64); font-family: DeepSeek-CJK-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Noto Sans&quot;, Ubuntu, Cantarell, &quot;Helvetica Neue&quot;, Oxygen, &quot;Open Sans&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; line-height: 28.575px;"> </span><span style="font-size: 0.875em; background-color: rgb(236, 236, 236); border-radius: 4px; color: rgb(64, 64, 64); font-family: Menlo, &quot;Roboto Mono&quot;, &quot;Courier New&quot;, Courier, monospace, Inter, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; line-height: 28.575px; font-weight: bold;">i</span><span style="font-size: 16.002px; color: rgb(64, 64, 64); font-family: DeepSeek-CJK-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Noto Sans&quot;, Ubuntu, Cantarell, &quot;Helvetica Neue&quot;, Oxygen, &quot;Open Sans&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; line-height: 28.575px;"> </span><span style="font-size: 16.002px; color: rgb(64, 64, 64); font-family: DeepSeek-CJK-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Noto Sans&quot;, Ubuntu, Cantarell, &quot;Helvetica Neue&quot;, Oxygen, &quot;Open Sans&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; line-height: 28.575px;">递减，直到处理完所有元素。</span></div></li></ol><h4 style="font-size: 16.002px; margin: 18.288px 0px 13.716px; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255);"><span style="font-size: 16.002px; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; color: rgb(64, 64, 64); font-family: DeepSeek-CJK-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Noto Sans&quot;, Ubuntu, Cantarell, &quot;Helvetica Neue&quot;, Oxygen, &quot;Open Sans&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: bold; line-height: 28.575px;">时间复杂度</span><span style="font-size: 16.002px; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; color: rgb(64, 64, 64); font-family: DeepSeek-CJK-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Noto Sans&quot;, Ubuntu, Cantarell, &quot;Helvetica Neue&quot;, Oxygen, &quot;Open Sans&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: bold; line-height: 28.575px;">：</span></h4><ul style="margin: 13.716px 0px; padding-left: 27.432px; font-size: 16.002px; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255);"><li><div style="margin-top: 0px; margin-right: 0px; margin-left: 0px; font-size: 16.002px; margin-bottom: 0px !important;"><span style="font-size: 16.002px; color: rgb(64, 64, 64); font-family: DeepSeek-CJK-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Noto Sans&quot;, Ubuntu, Cantarell, &quot;Helvetica Neue&quot;, Oxygen, &quot;Open Sans&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; line-height: 28.575px; font-weight: bold;">单次操作时间</span><span style="font-size: 16.002px; color: rgb(64, 64, 64); font-family: DeepSeek-CJK-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Noto Sans&quot;, Ubuntu, Cantarell, &quot;Helvetica Neue&quot;, Oxygen, &quot;Open Sans&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; line-height: 28.575px;">：每次仅需一次交换操作（O(1)）。</span></div></li><li style="margin-top: 4px;"><div style="margin-top: 0px; margin-right: 0px; margin-left: 0px; font-size: 16.002px; margin-bottom: 0px !important;"><span style="font-size: 16.002px; color: rgb(64, 64, 64); font-family: DeepSeek-CJK-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Noto Sans&quot;, Ubuntu, Cantarell, &quot;Helvetica Neue&quot;, Oxygen, &quot;Open Sans&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; line-height: 28.575px; font-weight: bold;">总时间复杂度</span><span style="font-size: 16.002px; color: rgb(64, 64, 64); font-family: DeepSeek-CJK-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Noto Sans&quot;, Ubuntu, Cantarell, &quot;Helvetica Neue&quot;, Oxygen, &quot;Open Sans&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; line-height: 28.575px;">：遍历</span><span style="font-size: 16.002px; color: rgb(64, 64, 64); font-family: DeepSeek-CJK-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Noto Sans&quot;, Ubuntu, Cantarell, &quot;Helvetica Neue&quot;, Oxygen, &quot;Open Sans&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; line-height: 28.575px;"> </span><span style="font-size: 0.875em; background-color: rgb(236, 236, 236); border-radius: 4px; color: rgb(64, 64, 64); font-family: Menlo, &quot;Roboto Mono&quot;, &quot;Courier New&quot;, Courier, monospace, Inter, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; line-height: 28.575px; font-weight: bold;">n-1</span><span style="font-size: 16.002px; color: rgb(64, 64, 64); font-family: DeepSeek-CJK-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Noto Sans&quot;, Ubuntu, Cantarell, &quot;Helvetica Neue&quot;, Oxygen, &quot;Open Sans&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; line-height: 28.575px;"> </span><span style="font-size: 16.002px; color: rgb(64, 64, 64); font-family: DeepSeek-CJK-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Noto Sans&quot;, Ubuntu, Cantarell, &quot;Helvetica Neue&quot;, Oxygen, &quot;Open Sans&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; line-height: 28.575px;">次，总时间为</span><span style="font-size: 16.002px; color: rgb(64, 64, 64); font-family: DeepSeek-CJK-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Noto Sans&quot;, Ubuntu, Cantarell, &quot;Helvetica Neue&quot;, Oxygen, &quot;Open Sans&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; line-height: 28.575px;"> </span><span style="font-size: 16.002px; color: rgb(64, 64, 64); font-family: DeepSeek-CJK-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Noto Sans&quot;, Ubuntu, Cantarell, &quot;Helvetica Neue&quot;, Oxygen, &quot;Open Sans&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; line-height: 28.575px; font-weight: bold;">O(n)</span><span style="font-size: 16.002px; color: rgb(64, 64, 64); font-family: DeepSeek-CJK-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Noto Sans&quot;, Ubuntu, Cantarell, &quot;Helvetica Neue&quot;, Oxygen, &quot;Open Sans&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; line-height: 28.575px;">。</span></div></li></ul><h4 style="font-size: 16.002px; margin: 18.288px 0px 13.716px; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255);"><span style="font-size: 16.002px; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255); color: rgb(64, 64, 64); font-family: DeepSeek-CJK-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Noto Sans&quot;, Ubuntu, Cantarell, &quot;Helvetica Neue&quot;, Oxygen, &quot;Open Sans&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: bold; line-height: 28.575px;">空间复杂度</span><span style="font-size: 16.002px; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255); color: rgb(64, 64, 64); font-family: DeepSeek-CJK-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Noto Sans&quot;, Ubuntu, Cantarell, &quot;Helvetica Neue&quot;, Oxygen, &quot;Open Sans&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: bold; line-height: 28.575px;">：</span></h4><ul style="margin: 13.716px 0px; padding-left: 27.432px; font-size: 16.002px; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255);"><li><div style="margin-top: 0px; margin-right: 0px; margin-left: 0px; font-size: 16.002px; margin-bottom: 0px !important;"><span style="font-size: 16.002px; color: rgb(64, 64, 64); font-family: DeepSeek-CJK-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Noto Sans&quot;, Ubuntu, Cantarell, &quot;Helvetica Neue&quot;, Oxygen, &quot;Open Sans&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; line-height: 28.575px;">原地操作，无需额外空间，空间复杂度为</span><span style="font-size: 16.002px; color: rgb(64, 64, 64); font-family: DeepSeek-CJK-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Noto Sans&quot;, Ubuntu, Cantarell, &quot;Helvetica Neue&quot;, Oxygen, &quot;Open Sans&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; line-height: 28.575px;"> </span><span style="font-size: 16.002px; color: rgb(64, 64, 64); font-family: DeepSeek-CJK-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Noto Sans&quot;, Ubuntu, Cantarell, &quot;Helvetica Neue&quot;, Oxygen, &quot;Open Sans&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; line-height: 28.575px; font-weight: bold;">O(1)</span><span style="font-size: 16.002px; color: rgb(64, 64, 64); font-family: DeepSeek-CJK-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Noto Sans&quot;, Ubuntu, Cantarell, &quot;Helvetica Neue&quot;, Oxygen, &quot;Open Sans&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; line-height: 28.575px;">。</span></div></li></ul><div style="margin-top: 0px; margin-right: 0px; margin-left: 0px; font-size: 16.002px; margin-bottom: 0px !important;"><br/></div><div style="box-sizing: border-box; padding: 8px; font-family: Monaco, Menlo, Consolas, &quot;Courier New&quot;, monospace; font-size: 12px; color: rgb(51, 51, 51); border-radius: 4px; background-color: rgb(251, 250, 248); border: 1px solid rgba(0, 0, 0, 0.15);-en-codeblock:true;"><div><br/></div></div><div style="margin-top: 0px; margin-right: 0px; margin-left: 0px; font-size: 16.002px; margin-bottom: 0px !important;"><br/></div><div style="margin-top: 0px; margin-right: 0px; margin-left: 0px; font-size: 16.002px; margin-bottom: 0px !important;"><br/></div></div><div><br/></div></span>
</div>
<hr>
<a name="803"/>

<div>
<span><div>游戏AI设计</div><div>通常指的是对非玩家角色行为的设计与研究,让他们能感知到周围的环境并且做出相应的动作表现</div><div>状态机 - 分层状态机 </div><div>行为树</div><div><img src="Evernote_files/Image [119].png" type="image/png" data-filename="Image.png"/></div><div>selector选择节点,选择其中一个子节点执行;比如今天吃什么</div><div>sequence序列节点,会从左到右执行子节点;比如制作披萨的过程</div><div><br/></div><div><br/></div></span>
</div>
<hr>
<a name="807"/>

<div>
<span><div><div><div><span style="font-weight: bold;">欧拉角和四元数</span></div><div><span style="font-size: 14pt;">万向锁 : </span><span style="letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: pre-line; font-size: 14pt; color: rgb(24, 25, 28); font-family: -apple-system, BlinkMacSystemFont, &quot;Helvetica Neue&quot;, Helvetica, Arial, &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">欧拉角描述</span><span style="font-size: 14pt; color: rgb(24, 25, 28); font-family: -apple-system, BlinkMacSystemFont, &quot;Helvetica Neue&quot;, Helvetica, Arial, &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: bold;">相对于初始状态</span><span style="letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: pre-line; font-size: 14pt; color: rgb(24, 25, 28); font-family: -apple-system, BlinkMacSystemFont, &quot;Helvetica Neue&quot;, Helvetica, Arial, &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">的变换，只和最终状态有关，与过程无关;这个是一个变换的过程,不是运动过程.</span></div><div style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); position: relative; white-space: pre-wrap; direction: ltr; text-align: left;"><font style="font-size: 14pt;"><span style="background-color: rgb(255, 255, 255);"><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); position: relative; white-space: pre-wrap; direction: ltr; font-size: 14pt; background-color: rgb(255, 255, 255); color: rgb(33, 33, 33); font-family: PingFangSC, Inter, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">unity里 当X轴角度为±90°时，</span></span></font></div><div style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); margin: 0px 0px 24px; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: pre-wrap; background-color: rgb(255, 255, 255);"><div style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); position: relative; white-space: pre-wrap; direction: ltr; text-align: left;"><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); position: relative; white-space: pre-wrap; direction: ltr;"><span style="color: rgb(33, 33, 33); font-family: PingFangSC, Inter, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; font-size: 14pt;">此时只有Z值是沿着自身Z轴旋转，且Y值旋转方向跟也是Z轴，丢失Y轴旋转自由度。</span></span></div></div><div><span style="letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: pre-wrap;"><span style="color: rgb(33, 33, 33); font-family: PingFangSC, Inter, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; font-size: 14pt;">unity 3D欧拉角的旋转顺序是：z-x-y,所以x轴在特定角度时会出现万向锁</span></span></div><div><br/></div><ul><li><div><span style="letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: pre-line;"><span style="color: rgb(24, 25, 28); font-family: -apple-system, BlinkMacSystemFont, &quot;Helvetica Neue&quot;, Helvetica, Arial, &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; font-size: 14pt;">x-y-z轴的变换顺序很重要,打乱变换顺序会导致结果不同</span></span></div></li><li><div><span style="letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: pre-line;"><span style="color: rgb(24, 25, 28); font-family: -apple-system, BlinkMacSystemFont, &quot;Helvetica Neue&quot;, Helvetica, Arial, &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; font-size: 14pt;">第一次10 - 90 -0 的变换是先x10,y90z0,第二次变换20-90-0,实际上是从初始状态到x20y90z0;而不是从10-90-0接着第二次旋转</span></span></div></li></ul><div><span style="letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: pre-line;"><span style="color: rgb(24, 25, 28); font-family: -apple-system, BlinkMacSystemFont, &quot;Helvetica Neue&quot;, Helvetica, Arial, &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; font-size: 14pt;">你输入的：沿x轴转10°，再沿y轴转90°，最后沿x轴转10° </span></span></div><div><span style="letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: pre-line;"><span style="color: rgb(24, 25, 28); font-family: -apple-system, BlinkMacSystemFont, &quot;Helvetica Neue&quot;, Helvetica, Arial, &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; font-size: 14pt;">你想象的：沿飞机的x轴转10°，再沿新得到的y轴转90°，最后沿刚刚得到的x轴转10° </span></span></div><div><span style="letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: pre-line;"><span style="color: rgb(24, 25, 28); font-family: -apple-system, BlinkMacSystemFont, &quot;Helvetica Neue&quot;, Helvetica, Arial, &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; font-size: 14pt;">你看到的：卧槽，为什么两次沿x轴转动方向不一样，绝逼是x轴没跟着动 </span></span></div><div><font style="font-size: 14pt;"><span style="letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: pre-line; font-size: 14pt; color: rgb(24, 25, 28); font-family: -apple-system, BlinkMacSystemFont, &quot;Helvetica Neue&quot;, Helvetica, Arial, &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">实际发生的：沿飞机的x轴转20°，再沿</span><span style="font-size: 14pt; color: rgb(24, 25, 28); font-family: -apple-system, BlinkMacSystemFont, &quot;Helvetica Neue&quot;, Helvetica, Arial, &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: bold;">新得到的y轴</span><span style="letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: pre-line; font-size: 14pt; color: rgb(24, 25, 28); font-family: -apple-system, BlinkMacSystemFont, &quot;Helvetica Neue&quot;, Helvetica, Arial, &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">转90°</span></font></div><div><span style="font-size: 12pt;"><br/></span></div><div><br/></div></div><div><span style="font-weight: bold;">四元数</span></div><div><span style="font-weight: bold; color: rgb(64, 64, 64); font-family: quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Noto Sans&quot;, Ubuntu, Cantarell, &quot;Helvetica Neue&quot;, Oxygen, &quot;Open Sans&quot;, sans-serif; font-size: 16.002px; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal;">欧拉角转换</span><span style="font-family: Menlo, &quot;Roboto Mono&quot;, &quot;Courier New&quot;, Courier, monospace, Inter, sans-serif; overflow: auto; white-space: pre-wrap; word-break: break-all; color: rgb(73, 73, 73); font-size: 12.573px; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;">Quaternion</span><span style="font-family: Menlo, &quot;Roboto Mono&quot;, &quot;Courier New&quot;, Courier, monospace, Inter, sans-serif; overflow: auto; white-space: pre-wrap; word-break: break-all; color: rgb(56, 58, 66); font-size: 12.573px; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;">.</span><span style="font-family: Menlo, &quot;Roboto Mono&quot;, &quot;Courier New&quot;, Courier, monospace, Inter, sans-serif; overflow: auto; white-space: pre-wrap; word-break: break-all; color: rgb(64, 120, 242); font-size: 12.573px; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;">Euler</span></div><div><span style="font-weight: bold; color: rgb(64, 64, 64); font-family: quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Noto Sans&quot;, Ubuntu, Cantarell, &quot;Helvetica Neue&quot;, Oxygen, &quot;Open Sans&quot;, sans-serif; font-size: 16.002px; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal;">轴角表示法</span><span style="font-family: Menlo, &quot;Roboto Mono&quot;, &quot;Courier New&quot;, Courier, monospace, Inter, sans-serif; overflow: auto; white-space: pre-wrap; word-break: break-all; color: rgb(73, 73, 73); font-size: 12.573px; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;">Quaternion</span><span style="font-family: Menlo, &quot;Roboto Mono&quot;, &quot;Courier New&quot;, Courier, monospace, Inter, sans-serif; overflow: auto; white-space: pre-wrap; word-break: break-all; color: rgb(56, 58, 66); font-size: 12.573px; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;">.</span><span style="font-family: Menlo, &quot;Roboto Mono&quot;, &quot;Courier New&quot;, Courier, monospace, Inter, sans-serif; overflow: auto; white-space: pre-wrap; word-break: break-all; color: rgb(64, 120, 242); font-size: 12.573px; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;">AngleAxis</span></div><div><span style="font-weight: bold; color: rgb(64, 64, 64); font-family: quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Noto Sans&quot;, Ubuntu, Cantarell, &quot;Helvetica Neue&quot;, Oxygen, &quot;Open Sans&quot;, sans-serif; font-size: 16.002px; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal;">看向目标方向</span><span style="font-family: Menlo, &quot;Roboto Mono&quot;, &quot;Courier New&quot;, Courier, monospace, Inter, sans-serif; overflow: auto; white-space: pre-wrap; word-break: break-all; color: rgb(73, 73, 73); font-size: 12.573px; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;">Quaternion</span><span style="font-family: Menlo, &quot;Roboto Mono&quot;, &quot;Courier New&quot;, Courier, monospace, Inter, sans-serif; overflow: auto; white-space: pre-wrap; word-break: break-all; color: rgb(56, 58, 66); font-size: 12.573px; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;">.</span><span style="font-family: Menlo, &quot;Roboto Mono&quot;, &quot;Courier New&quot;, Courier, monospace, Inter, sans-serif; overflow: auto; white-space: pre-wrap; word-break: break-all; color: rgb(64, 120, 242); font-size: 12.573px; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;">LookRotation</span></div><div><span style="font-weight: bold; color: rgb(64, 64, 64); font-family: quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Noto Sans&quot;, Ubuntu, Cantarell, &quot;Helvetica Neue&quot;, Oxygen, &quot;Open Sans&quot;, sans-serif; font-size: 16.002px; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal;">两点间方向</span><span style="font-family: Menlo, &quot;Roboto Mono&quot;, &quot;Courier New&quot;, Courier, monospace, Inter, sans-serif; overflow: auto; white-space: pre-wrap; word-break: break-all; color: rgb(73, 73, 73); font-size: 12.573px; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;">Quaternion</span><span style="font-family: Menlo, &quot;Roboto Mono&quot;, &quot;Courier New&quot;, Courier, monospace, Inter, sans-serif; overflow: auto; white-space: pre-wrap; word-break: break-all; color: rgb(56, 58, 66); font-size: 12.573px; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;">.</span><span style="font-family: Menlo, &quot;Roboto Mono&quot;, &quot;Courier New&quot;, Courier, monospace, Inter, sans-serif; overflow: auto; white-space: pre-wrap; word-break: break-all; color: rgb(64, 120, 242); font-size: 12.573px; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;">FromToRotation</span></div><div>tf.rotation = 四元数.欧拉角 * tf.rotation 左乘为绕世界坐标</div><div>tf.rotation =  tf.rotation *四元数.欧拉角 右乘为绕自身局部坐标</div><div><br/></div><div>slerp球面插值 - 永远不会出现绕180度的情况</div><div>lerp线性插值</div><ul style="margin: 13.716px 0px; padding-left: 27.432px; font-size: 16.002px; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255);"><li><div style="margin-top: 0px; margin-right: 0px; margin-left: 0px; font-size: 16.002px; margin-bottom: 0px !important;"><span style="font-size: 16.002px; color: rgb(64, 64, 64); font-family: quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Noto Sans&quot;, Ubuntu, Cantarell, &quot;Helvetica Neue&quot;, Oxygen, &quot;Open Sans&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; line-height: 28.575px; font-weight: bold;">视觉质量优先</span><span style="font-size: 16.002px; color: rgb(64, 64, 64); font-family: quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Noto Sans&quot;, Ubuntu, Cantarell, &quot;Helvetica Neue&quot;, Oxygen, &quot;Open Sans&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; line-height: 28.575px;"> </span><span style="font-size: 16.002px; color: rgb(64, 64, 64); font-family: quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Noto Sans&quot;, Ubuntu, Cantarell, &quot;Helvetica Neue&quot;, Oxygen, &quot;Open Sans&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; line-height: 28.575px;">→ 选Slerp</span></div></li><li style="margin-top: 4px;"><div style="margin-top: 0px; margin-right: 0px; margin-left: 0px; font-size: 16.002px; margin-bottom: 0px !important;"><span style="font-size: 16.002px; color: rgb(64, 64, 64); font-family: quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Noto Sans&quot;, Ubuntu, Cantarell, &quot;Helvetica Neue&quot;, Oxygen, &quot;Open Sans&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; line-height: 28.575px; font-weight: bold;">性能优先</span><span style="font-size: 16.002px; color: rgb(64, 64, 64); font-family: quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Noto Sans&quot;, Ubuntu, Cantarell, &quot;Helvetica Neue&quot;, Oxygen, &quot;Open Sans&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; line-height: 28.575px;"> </span><span style="font-size: 16.002px; color: rgb(64, 64, 64); font-family: quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Noto Sans&quot;, Ubuntu, Cantarell, &quot;Helvetica Neue&quot;, Oxygen, &quot;Open Sans&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; line-height: 28.575px;">→ 小角度用Lerp，大角度用Slerp</span></div></li></ul><div>组合旋转</div><div><span style="overflow: auto; white-space: pre-wrap; word-break: break-all; font-size: 12.573px; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; color: rgb(183, 107, 1); font-family: Menlo, &quot;Roboto Mono&quot;, &quot;Courier New&quot;, Courier, monospace, Inter, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">Quaternion</span> <span style="overflow: auto; white-space: pre-wrap; word-break: break-all; font-size: 12.573px; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; color: rgb(73, 73, 73); font-family: Menlo, &quot;Roboto Mono&quot;, &quot;Courier New&quot;, Courier, monospace, Inter, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">combined</span> <span style="overflow: auto; white-space: pre-wrap; word-break: break-all; font-size: 12.573px; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; color: rgb(64, 120, 242); font-family: Menlo, &quot;Roboto Mono&quot;, &quot;Courier New&quot;, Courier, monospace, Inter, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">=</span> <span style="overflow: auto; white-space: pre-wrap; word-break: break-all; font-size: 12.573px; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; color: rgb(73, 73, 73); font-family: Menlo, &quot;Roboto Mono&quot;, &quot;Courier New&quot;, Courier, monospace, Inter, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">rotationB</span> <span style="overflow: auto; white-space: pre-wrap; word-break: break-all; font-size: 12.573px; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; color: rgb(64, 120, 242); font-family: Menlo, &quot;Roboto Mono&quot;, &quot;Courier New&quot;, Courier, monospace, Inter, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">*</span> <span style="overflow: auto; white-space: pre-wrap; word-break: break-all; font-size: 12.573px; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; color: rgb(73, 73, 73); font-family: Menlo, &quot;Roboto Mono&quot;, &quot;Courier New&quot;, Courier, monospace, Inter, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">rotationA</span><span style="overflow: auto; white-space: pre-wrap; word-break: break-all; font-size: 12.573px; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; color: rgb(56, 58, 66); font-family: Menlo, &quot;Roboto Mono&quot;, &quot;Courier New&quot;, Courier, monospace, Inter, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">;</span> <span style="overflow: auto; white-space: pre-wrap; word-break: break-all; font-size: 12.573px; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; color: rgb(160, 161, 167); font-family: Menlo, &quot;Roboto Mono&quot;, &quot;Courier New&quot;, Courier, monospace, Inter, sans-serif; font-style: italic; font-variant-caps: normal; font-variant-ligatures: normal;">// 先A后B</span></div></div><div><br/></div></span>
</div>
<hr>
<a name="813"/>

<div>
<span><div><div><span style="font-size: 24pt; font-weight: bold;">知识点自查</span></div><div><span style="font-size: 24pt; font-weight: bold;">Asset Bundle</span></div><ol><li><div>什么是Asset bundle? ab包的物理组成?</div></li><li><div>为什么需要使用ab包?</div></li><li><div>介绍ab包压缩算法:lzma,lz4和不压缩</div></li><li><div> 加载api介绍 <span style="font-size: medium; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; color: rgb(25, 27, 31); font-family: -apple-system, BlinkMacSystemFont, &quot;Helvetica Neue&quot;, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Source Han Sans SC&quot;, &quot;Noto Sans CJK SC&quot;, &quot;WenQuanYi Micro Hei&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: bold;">LoadFromFile </span> <span style="font-size: medium; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; color: rgb(25, 27, 31); font-family: -apple-system, BlinkMacSystemFont, &quot;Helvetica Neue&quot;, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Source Han Sans SC&quot;, &quot;Noto Sans CJK SC&quot;, &quot;WenQuanYi Micro Hei&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: bold;">LoadFromMemory </span><span style="overflow: auto; white-space: pre-wrap; word-break: break-all; font-size: 12.573px; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; color: rgb(73, 73, 73); font-family: Menlo, &quot;Roboto Mono&quot;, &quot;Courier New&quot;, Courier, monospace, Inter, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">UnityWebRequestAssetBundle</span></div></li><li><div><span style="font-size: 9pt; color: rgb(73, 73, 73); font-family: Menlo;">依赖拆分黄金法则5个</span></div></li><li><div><span style="font-size: medium; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; color: rgb(25, 27, 31); font-family: -apple-system, BlinkMacSystemFont, &quot;Helvetica Neue&quot;, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Source Han Sans SC&quot;, &quot;Noto Sans CJK SC&quot;, &quot;WenQuanYi Micro Hei&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: bold;">资源相关目录介绍 resources streamingAssetPath persistentDataPath</span></div></li></ol><div><font style="font-size: 12pt;">点乘和叉乘在游戏中的运用</font></div></div><div><font style="font-size: 12pt;">万向锁如何形成的?</font></div><div><font style="font-size: 12pt;">四元数的api使用</font></div><div><span style="font-size: 24pt;"><br/></span></div><div><br/></div></span>
</div>
<hr>
<a name="821"/>

<div>
<span><div><div><div><b><font style="font-size: 18pt;">点乘和叉乘</font></b></div><h3 style="font-weight: bold; font-size: 18.288px; line-height: 1.5; margin: 18.288px 0px 13.716px; color: rgb(64, 64, 64); font-family: quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Noto Sans&quot;, Ubuntu, Cantarell, &quot;Helvetica Neue&quot;, Oxygen, &quot;Open Sans&quot;, sans-serif; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255);"><span style="font-weight: bold; font-size: 18.288px; line-height: 1.5; color: rgb(64, 64, 64); font-family: quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Noto Sans&quot;, Ubuntu, Cantarell, &quot;Helvetica Neue&quot;, Oxygen, &quot;Open Sans&quot;, sans-serif; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal;">一、点乘（Dot Product）</span></h3><div><span style="font-size: 14pt; color: rgb(64, 64, 64); font-family: quote-cjk-patch;"><b>点乘 : 表示两个向量方向的相似度,返回一个标量</b></span></div><p style="margin: 13.716px 0px; font-size: 16.002px; line-height: 28.575px; color: rgb(64, 64, 64); font-family: quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Noto Sans&quot;, Ubuntu, Cantarell, &quot;Helvetica Neue&quot;, Oxygen, &quot;Open Sans&quot;, sans-serif; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255);"></p><div><span style="font-weight: bold;">公式</span>：<span style="font-size: 0.875em; font-weight: bold; font-family: Menlo, &quot;Roboto Mono&quot;, &quot;Courier New&quot;, Courier, monospace, Inter, sans-serif; background-color: rgb(236, 236, 236); border-radius: 4px;">a·b = |a||b|cosθ</span></div><div style="margin-top: 1em; margin-bottom: 1em;"><span style="font-weight: bold;-en-paragraph:true;">Unity API</span><span style="-en-paragraph:true;">：</span><span style="font-size: 0.875em; font-weight: bold; font-family: Menlo, &quot;Roboto Mono&quot;, &quot;Courier New&quot;, Courier, monospace, Inter, sans-serif; background-color: rgb(236, 236, 236); border-radius: 4px;-en-paragraph:true;">Vector3.Dot(a, b)</span></div><ul><li><div>计算两个向量的夹角</div></li><li><div>计算一个向量在另一个向量上的投影</div></li><li><div>判断方向,结果大于0,方向基本相同;=0 垂直</div></li><li><div>判断物体是否在另一个物体的前方或者后方</div></li></ul><h4 style="font-weight: bold; font-size: 16.002px; line-height: 28.575px; margin: 18.288px 0px 13.716px; color: rgb(64, 64, 64); font-family: quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Noto Sans&quot;, Ubuntu, Cantarell, &quot;Helvetica Neue&quot;, Oxygen, &quot;Open Sans&quot;, sans-serif; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255);"><span style="font-weight: bold; font-size: 16.002px; line-height: 28.575px; color: rgb(64, 64, 64); font-family: quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Noto Sans&quot;, Ubuntu, Cantarell, &quot;Helvetica Neue&quot;, Oxygen, &quot;Open Sans&quot;, sans-serif; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal;">应用场景及代码示例：</span></h4><div style="margin: 0px 0px 4px; font-size: 16.002px; line-height: 28.575px; color: rgb(64, 64, 64); font-family: quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Noto Sans&quot;, Ubuntu, Cantarell, &quot;Helvetica Neue&quot;, Oxygen, &quot;Open Sans&quot;, sans-serif; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255);"><span style="font-size: 16.002px; line-height: 28.575px; color: rgb(64, 64, 64); font-family: quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Noto Sans&quot;, Ubuntu, Cantarell, &quot;Helvetica Neue&quot;, Oxygen, &quot;Open Sans&quot;, sans-serif; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; font-weight: bold;">判断对象相对方向</span></div><ul style="margin: 4px 0px 0px; padding-left: 27.432px; color: rgb(64, 64, 64); font-family: quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Noto Sans&quot;, Ubuntu, Cantarell, &quot;Helvetica Neue&quot;, Oxygen, &quot;Open Sans&quot;, sans-serif; font-size: 16.002px; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255);"><li><div style="margin: 0px 0px 4px; font-size: 16.002px; line-height: 28.575px;"><span style="font-size: 16.002px; line-height: 28.575px;">检测敌人在玩家前方还是后方：</span></div></li></ul><div style="box-sizing: border-box; padding: 8px; font-family: Monaco, Menlo, Consolas, &quot;Courier New&quot;, monospace; font-size: 12px; color: rgb(51, 51, 51); border-radius: 4px; background-color: rgb(251, 250, 248); border: 1px solid rgba(0, 0, 0, 0.15);-en-codeblock:true;"><div>Vector3 toEnemy = enemy.position - player.position;</div><div>float dot = Vector3.Dot(player.forward, toEnemy.normalized);</div><div><br/></div><div><br/></div><div>if (dot &gt; 0) {</div><div>    Debug.Log(&quot;敌人在玩家前方&quot;);</div><div>} else if (dot &lt; 0) {</div><div>    Debug.Log(&quot;敌人在玩家后方&quot;);</div><div>}</div></div><div style="margin: 0px 0px 4px; font-size: 16.002px; line-height: 28.575px; color: rgb(64, 64, 64); font-family: quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Noto Sans&quot;, Ubuntu, Cantarell, &quot;Helvetica Neue&quot;, Oxygen, &quot;Open Sans&quot;, sans-serif; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255);"><span style="font-size: 16.002px; line-height: 28.575px; color: rgb(64, 64, 64); font-family: quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Noto Sans&quot;, Ubuntu, Cantarell, &quot;Helvetica Neue&quot;, Oxygen, &quot;Open Sans&quot;, sans-serif; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; font-weight: bold;">计算光照强度（Lambert光照模型）</span></div><ul style="margin: 4px 0px 0px; padding-left: 27.432px; color: rgb(64, 64, 64); font-family: quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Noto Sans&quot;, Ubuntu, Cantarell, &quot;Helvetica Neue&quot;, Oxygen, &quot;Open Sans&quot;, sans-serif; font-size: 16.002px; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255);"><li><div style="margin: 0px 0px 4px; font-size: 16.002px; line-height: 28.575px;"><span style="font-size: 16.002px; line-height: 28.575px;">漫反射光照计算：</span></div></li></ul><div style="box-sizing: border-box; padding: 8px; font-family: Monaco, Menlo, Consolas, &quot;Courier New&quot;, monospace; font-size: 12px; color: rgb(51, 51, 51); border-radius: 4px; background-color: rgb(251, 250, 248); border: 1px solid rgba(0, 0, 0, 0.15);-en-codeblock:true;"><div>Vector3 lightDir = (light.position - vertex.position).normalized;</div><div>float intensity = Mathf.Max(0, Vector3.Dot(normal, lightDir));</div><div>Color diffuse = light.color * intensity;</div></div><div style="margin: 0px 0px 4px; font-size: 16.002px; line-height: 28.575px; color: rgb(64, 64, 64); font-family: quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Noto Sans&quot;, Ubuntu, Cantarell, &quot;Helvetica Neue&quot;, Oxygen, &quot;Open Sans&quot;, sans-serif; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255);"><span style="font-size: 16.002px; line-height: 28.575px; color: rgb(64, 64, 64); font-family: quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Noto Sans&quot;, Ubuntu, Cantarell, &quot;Helvetica Neue&quot;, Oxygen, &quot;Open Sans&quot;, sans-serif; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; font-weight: bold;">检测视野范围（如扇形FOV）</span></div><ul style="margin: 4px 0px 0px; padding-left: 27.432px; color: rgb(64, 64, 64); font-family: quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Noto Sans&quot;, Ubuntu, Cantarell, &quot;Helvetica Neue&quot;, Oxygen, &quot;Open Sans&quot;, sans-serif; font-size: 16.002px; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255);"><li><div style="margin: 0px 0px 4px; font-size: 16.002px; line-height: 28.575px;"><span style="font-size: 16.002px; line-height: 28.575px;">判断目标是否在视角内（结合角度阈值）：</span></div></li></ul><div style="box-sizing: border-box; padding: 8px; font-family: Monaco, Menlo, Consolas, &quot;Courier New&quot;, monospace; font-size: 12px; color: rgb(51, 51, 51); border-radius: 4px; background-color: rgb(251, 250, 248); border: 1px solid rgba(0, 0, 0, 0.15);-en-codeblock:true;"><div>Vector3 toTarget = target.position - transform.position;</div><div>float angle = Vector3.Angle(transform.forward, toTarget); // 基于点乘封装</div><div>if (angle &lt; maxViewAngle) {</div><div>    Debug.Log(&quot;目标在视野内&quot;);</div><div>}</div></div><div><br/></div><h3 style="font-weight: bold; font-size: 18.288px; line-height: 1.5; margin: 18.288px 0px 13.716px; color: rgb(64, 64, 64); font-family: quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Noto Sans&quot;, Ubuntu, Cantarell, &quot;Helvetica Neue&quot;, Oxygen, &quot;Open Sans&quot;, sans-serif; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255);"><span style="font-weight: bold; font-size: 18.288px; line-height: 1.5; color: rgb(64, 64, 64); font-family: quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Noto Sans&quot;, Ubuntu, Cantarell, &quot;Helvetica Neue&quot;, Oxygen, &quot;Open Sans&quot;, sans-serif; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255);">二、叉乘（Cross Product）</span></h3><p style="margin: 13.716px 0px; font-size: 16.002px; line-height: 28.575px; color: rgb(64, 64, 64); font-family: quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Noto Sans&quot;, Ubuntu, Cantarell, &quot;Helvetica Neue&quot;, Oxygen, &quot;Open Sans&quot;, sans-serif; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255);"></p><div><span style="font-weight: bold;">公式</span>：<span style="font-size: 0.875em; font-weight: bold; font-family: Menlo, &quot;Roboto Mono&quot;, &quot;Courier New&quot;, Courier, monospace, Inter, sans-serif; background-color: rgb(236, 236, 236); border-radius: 4px;">a×b = |a||b|sinθ * n</span>（结果是一个垂直于a、b平面的向量）</div><div style="margin-top: 1em; margin-bottom: 1em;"><span style="font-weight: bold;-en-paragraph:true;">Unity API</span><span style="-en-paragraph:true;">：</span><span style="font-size: 0.875em; font-weight: bold; font-family: Menlo, &quot;Roboto Mono&quot;, &quot;Courier New&quot;, Courier, monospace, Inter, sans-serif; background-color: rgb(236, 236, 236); border-radius: 4px;-en-paragraph:true;">Vector3.Cross(a, b)</span></div></div><div><span style="font-weight: bold; font-size: 16.002px; line-height: 28.575px; color: rgb(64, 64, 64); font-family: quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Noto Sans&quot;, Ubuntu, Cantarell, &quot;Helvetica Neue&quot;, Oxygen, &quot;Open Sans&quot;, sans-serif; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal;">应用场景及代码示例：</span></div><div style="margin: 0px 0px 4px; font-size: 16.002px; line-height: 28.575px; color: rgb(64, 64, 64); font-family: quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Noto Sans&quot;, Ubuntu, Cantarell, &quot;Helvetica Neue&quot;, Oxygen, &quot;Open Sans&quot;, sans-serif; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255);"><span style="font-size: 16.002px; line-height: 28.575px; color: rgb(64, 64, 64); font-family: quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Noto Sans&quot;, Ubuntu, Cantarell, &quot;Helvetica Neue&quot;, Oxygen, &quot;Open Sans&quot;, sans-serif; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255); font-weight: bold;">计算表面法线</span></div><ul style="margin: 4px 0px 0px; padding-left: 27.432px; color: rgb(64, 64, 64); font-family: quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Noto Sans&quot;, Ubuntu, Cantarell, &quot;Helvetica Neue&quot;, Oxygen, &quot;Open Sans&quot;, sans-serif; font-size: 16.002px; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255);"><li><div style="margin: 0px 0px 4px; font-size: 16.002px; line-height: 28.575px;"><span style="font-size: 16.002px; line-height: 28.575px;">通过三角形顶点生成法线：</span></div></li></ul><div style="box-sizing: border-box; padding: 8px; font-family: Monaco, Menlo, Consolas, &quot;Courier New&quot;, monospace; font-size: 12px; color: rgb(51, 51, 51); border-radius: 4px; background-color: rgb(251, 250, 248); border: 1px solid rgba(0, 0, 0, 0.15);-en-codeblock:true;"><div>Vector3 v1 = pointB - pointA;</div><div>Vector3 v2 = pointC - pointA;</div><div>Vector3 normal = Vector3.Cross(v1, v2).normalized; // 注意归一化</div></div><div style="margin: 0px 0px 4px; font-size: 16.002px; line-height: 28.575px; color: rgb(64, 64, 64); font-family: quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Noto Sans&quot;, Ubuntu, Cantarell, &quot;Helvetica Neue&quot;, Oxygen, &quot;Open Sans&quot;, sans-serif; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255);"><span style="font-size: 16.002px; line-height: 28.575px; color: rgb(64, 64, 64); font-family: quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Noto Sans&quot;, Ubuntu, Cantarell, &quot;Helvetica Neue&quot;, Oxygen, &quot;Open Sans&quot;, sans-serif; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; font-weight: bold;">确定旋转方向 &gt;0目标在右侧</span></div><ul style="margin: 4px 0px 0px; padding-left: 27.432px; color: rgb(64, 64, 64); font-family: quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Noto Sans&quot;, Ubuntu, Cantarell, &quot;Helvetica Neue&quot;, Oxygen, &quot;Open Sans&quot;, sans-serif; font-size: 16.002px; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255);"><li><div style="margin: 0px 0px 4px; font-size: 16.002px; line-height: 28.575px;"><span style="font-size: 16.002px; line-height: 28.575px;">控制角色转向目标时的左右方向：</span></div></li></ul><div style="box-sizing: border-box; padding: 8px; font-family: Monaco, Menlo, Consolas, &quot;Courier New&quot;, monospace; font-size: 12px; color: rgb(51, 51, 51); border-radius: 4px; background-color: rgb(251, 250, 248); border: 1px solid rgba(0, 0, 0, 0.15);-en-codeblock:true;"><div>Vector3 toTarget = target.position - transform.position;</div><div>Vector3 cross = Vector3.Cross(transform.forward, toTarget);</div><div>if (cross.y &gt; 0) {</div><div>    TurnRight(); // 目标在右侧</div><div>} else if (cross.y &lt; 0) {</div><div>    TurnLeft();  // 目标在左侧</div><div>}</div></div><div style="margin: 0px 0px 4px; font-size: 16.002px; line-height: 28.575px; color: rgb(64, 64, 64); font-family: quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Noto Sans&quot;, Ubuntu, Cantarell, &quot;Helvetica Neue&quot;, Oxygen, &quot;Open Sans&quot;, sans-serif; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255);"><span style="font-size: 16.002px; line-height: 28.575px; color: rgb(64, 64, 64); font-family: quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Noto Sans&quot;, Ubuntu, Cantarell, &quot;Helvetica Neue&quot;, Oxygen, &quot;Open Sans&quot;, sans-serif; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255); font-weight: bold;">生成切线空间（TBN矩阵）</span></div><ul style="margin: 4px 0px 0px; padding-left: 27.432px; color: rgb(64, 64, 64); font-family: quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Noto Sans&quot;, Ubuntu, Cantarell, &quot;Helvetica Neue&quot;, Oxygen, &quot;Open Sans&quot;, sans-serif; font-size: 16.002px; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255);"><li><div style="margin: 0px 0px 4px; font-size: 16.002px; line-height: 28.575px;"><span style="font-size: 16.002px; line-height: 28.575px;">法线贴图所需的切线空间计算：</span></div></li></ul><div style="box-sizing: border-box; padding: 8px; font-family: Monaco, Menlo, Consolas, &quot;Courier New&quot;, monospace; font-size: 12px; color: rgb(51, 51, 51); border-radius: 4px; background-color: rgb(251, 250, 248); border: 1px solid rgba(0, 0, 0, 0.15);-en-codeblock:true;"><div>Vector3 tangent = Vector3.Cross(normal, Vector3.up).normalized;</div><div>Vector3 binormal = Vector3.Cross(normal, tangent);</div><div>Matrix4x4 TBN = new Matrix4x4(tangent, binormal, normal, Vector4.zero);</div></div><div style="margin: 0px 0px 4px; font-size: 16.002px; line-height: 28.575px;"><br/></div><div style="margin: 0px 0px 4px; font-size: 16.002px; line-height: 28.575px;"><br/></div><div style="margin: 0px 0px 4px; font-size: 16.002px; line-height: 28.575px;"><br/></div></div></span>
</div>
<hr>
<a name="823"/>

<div><span><div><a href="Evernote_files/unityshader中_worldSpaceLightPos0和unityWorldspacelightDir方法返回的结果有什么区别.pdf"><img src="Evernote_files/627803892c7363e8f4676101cf11a2c3.png" alt="unityshader中_worldSpaceLightPos0和unityWorldspacelightDir方法返回的结果有什么区别.pdf"></a></div><div><br/></div></span>
</div>
<hr>
<a name="826"/>

<div><span><div><a href="Evernote_files/unityshader中_worldSpaceLightPos0和unityWorldspacelightDir方法返回的结果有什么区别(1).docx"><img src="Evernote_files/09205d5af707f10def1c654a97bc35f0.png" alt="unityshader中_worldSpaceLightPos0和unityWorldspacelightDir方法返回的结果有什么区别(1).docx"></a></div><div><br/></div></span>
</div>
<hr>
<a name="835"/>

<div>
<span><div><div><div><div>面试遇到问题</div><div>王者外包一面:</div><ul><li><div>injectFix使用限制情况</div></li><li><div>如何实现简历中scrollRect的缩放功能</div></li><li><div>介绍你如何维护项目的版本</div></li><li><div>介绍简历中热更配置表流程实现</div></li><li><div>mvc模式在工作中存在的缺点</div></li><li><div>C#列表和字典的内部组成原理</div></li><li><div>lua是如何实现继承的</div></li><li><div>介绍一下ts语言的一些特点</div></li><li><div>2d跑酷不用引擎物理系统的前提下如何实现碰撞检测</div></li><li><div>加载大内存预制体界面,比如十几个界面遇到卡顿该帧解决</div></li></ul><div>王者外包二面:</div><ul><li><div>介绍协程概念以及底层实现</div></li><li><div>介绍UGUI的锚点和轴心点</div></li><li><div>ugui的重建机制</div></li><li><div>ui在不同屏幕的自适应解决方案</div></li><li><div>深度缓存区的作用?1024*1024像素缓冲区大小是多少?</div></li><li><div>介绍最拿手的项目</div></li></ul><div><br/></div></div><div>IGG</div><ul><li><div>垃圾回收机制触发时机?主动触发还有呢?</div></li><li><div>如何随机不重复的数</div></li><li><div>两个顺序数组合并成一个并且要顺序排序</div></li><li><div>unity上下文机制和c#上下文机制有什么不同</div></li><li><div>缓存池实现,不同缓存池如何做到不同的扩容.缓存池满了再加入元素做销毁行为是正确的吗</div></li><li><div>  <span style="letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(235, 238, 242); box-sizing: border-box; font-size: 14px; border-radius: 6px; display: inline-flex; color: rgb(15, 17, 21); font-family: Menlo, Monaco, &quot;Cascadia Mono&quot;, Consolas, &quot;Ubuntu Mono&quot;, &quot;DejaVu Sans Mono&quot;, &quot;Liberation Mono&quot;, &quot;JetBrains Mono&quot;, &quot;Fira Code&quot;, Cousine, &quot;Roboto Mono&quot;, &quot;Courier New&quot;, Courier, sans-serif, system-ui; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: 400; line-height: 22px;">AssetBundle.LoadFromFile </span><span style="font-weight: bold;">细节</span>：它并不会将整个AssetBundle文件加载到内存中，<span style="font-weight: bold; text-decoration: underline;">而是仅仅读取其头部信息，建立映射</span>。当你调用 <span style="box-sizing: border-box; font-size: 14px; background-color: rgb(235, 238, 242); border-radius: 6px; display: inline-flex; font-family: Menlo, Monaco, &quot;Cascadia Mono&quot;, Consolas, &quot;Ubuntu Mono&quot;, &quot;DejaVu Sans Mono&quot;, &quot;Liberation Mono&quot;, &quot;JetBrains Mono&quot;, &quot;Fira Code&quot;, Cousine, &quot;Roboto Mono&quot;, &quot;Courier New&quot;, Courier, sans-serif, system-ui; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: 400; line-height: 22px;">LoadAsset</span> 时，它才按需从磁盘读取所需的资产块。</div></li><li><div>二面</div></li><ul><li><div>动态障碍寻路如何解决</div></li><li><div>为什么用有限状态机去重构热更配置表?好处是什么</div></li></ul><ul><li><div>结构体和类的使用时机</div></li><li><div>闭包的底层实现以及消耗探究,用局部变量,用成员变量,用静态变量</div></li><li><div>await task后的线程是主线程吗?</div></li><li><div>buff来源数据杂如何解决</div></li><li><div>配置表太多占用内存如何解决</div></li><li><div>不用时间轮轮如何去管理定时任务管理器</div></li><li><div>图形渲染中阴影是怎么实现的</div></li></ul></ul><div><br/></div></div><div>冰川:</div><ul><li><div>A星如何找出邻居周围最小代价的点</div></li><li><div>时间轮步进映射</div></li><li><div><span style="font-size: unset; color: unset; font-family: unset;">如何检测mesh内存泄漏</span></div></li><li><div><span style="font-size: unset; color: unset; font-family: unset;">打包的纹理是使用什么格式</span></div></li><li><div><span style="font-size: unset; color: unset; font-family: unset;">如何排查死锁,照成死锁的原因</span></div></li><li><div><span style="font-size: unset; color: unset; font-family: unset;">检视器编辑器客制化按钮点击样式</span></div></li><li><div><span style="font-size: unset; color: unset; font-family: unset;">ab包什么时机卸载</span></div></li></ul><div>游卡:</div></div><div>动态的Hud如何合批?合批的机制</div><div>跳表搜索 - 优化open List</div><div><br/></div></span>
</div>
<hr>
<a name="837"/>

<div>
<span><div><div><span style="font-weight: bold; font-size: 24pt;">IGG二面</span></div><ul><li><div>动态障碍寻路如何解决</div></li><li><div>buff来源数据杂如何解决</div></li><li><div>配置表太多占用内存如何解决</div></li><li><div>不用时间轮,如何去管理定时任务管理器?</div></li><ul><li><div>基于二叉堆的优先队列, <span style="color: rgb(15, 17, 21); font-family: quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, Oxygen, Ubuntu, Cantarell, &quot;Open Sans&quot;, &quot;Helvetica Neue&quot;, sans-serif; font-size: 16px; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal;">添加是O(log n)</span></div></li></ul><li><div>为什么用有限状态机去重构热更配置表?好处是什么</div></li><ul><li><div><span style="font-size: 16px; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; color: rgb(15, 17, 21); font-family: quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, Oxygen, Ubuntu, Cantarell, &quot;Open Sans&quot;, &quot;Helvetica Neue&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">逻辑清晰易维护: 在没有状态机的情况下，系统的状态通常通过一系列标志位（</span><span style="box-sizing: border-box; font-variation-settings: normal; background-color: rgb(235, 238, 242); border-radius: 6px; display: inline-flex; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; font-size: 0.875em; color: rgb(15, 17, 21); font-family: Menlo, Monaco, &quot;Cascadia Mono&quot;, Consolas, &quot;Ubuntu Mono&quot;, &quot;DejaVu Sans Mono&quot;, &quot;Liberation Mono&quot;, &quot;JetBrains Mono&quot;, &quot;Fira Code&quot;, Cousine, &quot;Roboto Mono&quot;, &quot;Courier New&quot;, Courier, sans-serif, system-ui; font-feature-settings: normal; font-kerning: auto; font-stretch: 100%; font-variant: normal; line-height: 22px;">is_loading</span><span style="font-size: 16px; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255); color: rgb(15, 17, 21); font-family: quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, Oxygen, Ubuntu, Cantarell, &quot;Open Sans&quot;, &quot;Helvetica Neue&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">,</span><span style="font-size: 16px; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255); color: rgb(15, 17, 21); font-family: quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, Oxygen, Ubuntu, Cantarell, &quot;Open Sans&quot;, &quot;Helvetica Neue&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;"> </span><span style="box-sizing: border-box; font-variation-settings: normal; background-color: rgb(235, 238, 242); border-radius: 6px; display: inline-flex; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; font-size: 0.875em; color: rgb(15, 17, 21); font-family: Menlo, Monaco, &quot;Cascadia Mono&quot;, Consolas, &quot;Ubuntu Mono&quot;, &quot;DejaVu Sans Mono&quot;, &quot;Liberation Mono&quot;, &quot;JetBrains Mono&quot;, &quot;Fira Code&quot;, Cousine, &quot;Roboto Mono&quot;, &quot;Courier New&quot;, Courier, sans-serif, system-ui; font-feature-settings: normal; font-kerning: auto; font-stretch: 100%; font-variant: normal; line-height: 22px;">is_success</span><span style="font-size: 16px; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; color: rgb(15, 17, 21); font-family: quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, Oxygen, Ubuntu, Cantarell, &quot;Open Sans&quot;, &quot;Helvetica Neue&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">,</span><span style="font-size: 16px; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; color: rgb(15, 17, 21); font-family: quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, Oxygen, Ubuntu, Cantarell, &quot;Open Sans&quot;, &quot;Helvetica Neue&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;"> </span><span style="box-sizing: border-box; font-variation-settings: normal; background-color: rgb(235, 238, 242); border-radius: 6px; display: inline-flex; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; font-size: 0.875em; color: rgb(15, 17, 21); font-family: Menlo, Monaco, &quot;Cascadia Mono&quot;, Consolas, &quot;Ubuntu Mono&quot;, &quot;DejaVu Sans Mono&quot;, &quot;Liberation Mono&quot;, &quot;JetBrains Mono&quot;, &quot;Fira Code&quot;, Cousine, &quot;Roboto Mono&quot;, &quot;Courier New&quot;, Courier, sans-serif, system-ui; font-feature-settings: normal; font-kerning: auto; font-stretch: 100%; font-variant: normal; line-height: 22px;">has_error</span><span style="font-size: 16px; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; color: rgb(15, 17, 21); font-family: quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, Oxygen, Ubuntu, Cantarell, &quot;Open Sans&quot;, &quot;Helvetica Neue&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">）和大量的</span><span style="font-size: 16px; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; color: rgb(15, 17, 21); font-family: quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, Oxygen, Ubuntu, Cantarell, &quot;Open Sans&quot;, &quot;Helvetica Neue&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;"> </span><span style="box-sizing: border-box; font-variation-settings: normal; background-color: rgb(235, 238, 242); border-radius: 6px; display: inline-flex; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; font-size: 0.875em; color: rgb(15, 17, 21); font-family: Menlo, Monaco, &quot;Cascadia Mono&quot;, Consolas, &quot;Ubuntu Mono&quot;, &quot;DejaVu Sans Mono&quot;, &quot;Liberation Mono&quot;, &quot;JetBrains Mono&quot;, &quot;Fira Code&quot;, Cousine, &quot;Roboto Mono&quot;, &quot;Courier New&quot;, Courier, sans-serif, system-ui; font-feature-settings: normal; font-kerning: auto; font-stretch: 100%; font-variant: normal; line-height: 22px;">if-else</span><span style="font-size: 16px; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; color: rgb(15, 17, 21); font-family: quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, Oxygen, Ubuntu, Cantarell, &quot;Open Sans&quot;, &quot;Helvetica Neue&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;"> </span><span style="font-size: 16px; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255); color: rgb(15, 17, 21); font-family: quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, Oxygen, Ubuntu, Cantarell, &quot;Open Sans&quot;, &quot;Helvetica Neue&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">或</span><span style="font-size: 16px; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255); color: rgb(15, 17, 21); font-family: quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, Oxygen, Ubuntu, Cantarell, &quot;Open Sans&quot;, &quot;Helvetica Neue&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;"> </span><span style="box-sizing: border-box; font-variation-settings: normal; background-color: rgb(235, 238, 242); border-radius: 6px; display: inline-flex; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; font-size: 0.875em; color: rgb(15, 17, 21); font-family: Menlo, Monaco, &quot;Cascadia Mono&quot;, Consolas, &quot;Ubuntu Mono&quot;, &quot;DejaVu Sans Mono&quot;, &quot;Liberation Mono&quot;, &quot;JetBrains Mono&quot;, &quot;Fira Code&quot;, Cousine, &quot;Roboto Mono&quot;, &quot;Courier New&quot;, Courier, sans-serif, system-ui; font-feature-settings: normal; font-kerning: auto; font-stretch: 100%; font-variant: normal; line-height: 22px;">switch-case</span><span style="font-size: 16px; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255); color: rgb(15, 17, 21); font-family: quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, Oxygen, Ubuntu, Cantarell, &quot;Open Sans&quot;, &quot;Helvetica Neue&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;"> </span><span style="font-size: 16px; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; color: rgb(15, 17, 21); font-family: quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, Oxygen, Ubuntu, Cantarell, &quot;Open Sans&quot;, &quot;Helvetica Neue&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">语句来管理。这种“意大利面条式”的代码会散落在各个角落，难以理解，更容易出错。</span></div></li><li><div><span style="font-size: 12pt; color: rgb(15, 17, 21); font-family: quote-cjk-patch;">易拓展</span></div></li><li><div><span style="font-size: 12pt; color: rgb(15, 17, 21); font-family: quote-cjk-patch;">可读性高</span></div></li><li><div>容易定位bug</div></li><li><div><span style="font-size: 16px; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: pre-wrap; background-color: rgb(237, 243, 254); color: rgb(15, 17, 21); font-family: quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, Oxygen, Ubuntu, Cantarell, &quot;Open Sans&quot;, &quot;Helvetica Neue&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">重构流程比较固定的系统,状态机的好处是什么?</span></div></li><ul><li><div><span style="font-size: 12pt; color: rgb(15, 17, 21); font-family: quote-cjk-patch;">对拓展进行保留</span></div></li><li><div><span style="color: rgb(15, 17, 21); font-family: quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, Oxygen, Ubuntu, Cantarell, &quot;Open Sans&quot;, &quot;Helvetica Neue&quot;, sans-serif; font-size: 16px; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal;">对于流程固定的系统，状态机不止是一个实现细节,我觉得他是一种对系统构建的一个态度;让一个运行的代码提升到一个设计思想的代码实践</span></div></li></ul></ul><li><div>结构体和类的使用时机</div></li><ul><li><div>结构体</div></li><ul><li><div>小类型数据16字节以下</div></li><li><div>频繁实例化且生命周期短</div></li><li><div>需要避免垃圾回收影响的性能场景</div></li></ul><li><div>类</div></li><ul><li><div>复杂结构对象</div></li><li><div>需要引用共享的对象</div></li><li><div>需要继承或者多态</div></li></ul><li><div>C# 成员的内存分配</div></li><ul><li><div>class的内存分配: 1.类示例本身在堆上2.所有成员(包括值类型成员)都作为类示例的一部分存储在堆中</div></li><li><div>方法中的局部变量存储在栈上</div></li><li><div>struct的内存分配: <span style="font-weight: bold; color: rgb(15, 17, 21); font-family: quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, Oxygen, Ubuntu, Cantarell, &quot;Open Sans&quot;, &quot;Helvetica Neue&quot;, sans-serif; font-size: 16px; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal;">结构体成员的内存位置取决于结构体本身存储在什么地方</span></div></li><li><div><span style="font-weight: bold; color: rgb(15, 17, 21); font-family: quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, Oxygen, Ubuntu, Cantarell, &quot;Open Sans&quot;, &quot;Helvetica Neue&quot;, sans-serif; font-size: 16px; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal;">结构体中的引用类型成员存储的是引用（指针），而不是实际的对象数据。引用本身存储在结构体所在的位置，而实际的对象数据始终存储在堆（Heap）上。</span></div></li></ul></ul><li><div>闭包的底层实现</div></li><ul><li><div><span style="color: rgb(25, 27, 31); font-family: -apple-system, BlinkMacSystemFont, &quot;Helvetica Neue&quot;, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Source Han Sans SC&quot;, &quot;Noto Sans CJK SC&quot;, &quot;WenQuanYi Micro Hei&quot;, &quot;MiSans L3&quot;, &quot;Segoe UI&quot;, sans-serif; font-size: medium; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal;">闭包是使用的<b>变量已经脱离其作用域</b>，由于<b>变量和作用域之间存在上下文关系，从而可以在当前环境中继续使用</b></span></div></li><li><div><span style="color: rgb(25, 27, 31);"><b><br/></b></span></div></li><li><div><b>陷阱</b> =&gt; <span style="font-weight: bold; color: rgb(15, 17, 21); font-family: quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, Oxygen, Ubuntu, Cantarell, &quot;Open Sans&quot;, &quot;Helvetica Neue&quot;, sans-serif; font-size: 16px; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal;">始终记住，闭包捕获的是变量引用，而不是值</span></div></li><ul><li><div>循环变量捕获,捕获了用于循环的for_i ==&gt; <span style="font-weight: bold; color: rgb(15, 17, 21); font-family: quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, Oxygen, Ubuntu, Cantarell, &quot;Open Sans&quot;, &quot;Helvetica Neue&quot;, sans-serif; font-size: 15px; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal;">在循环内部创建局部变量副本</span></div></li><li><div><span style="color: rgb(15, 17, 21); font-family: quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, Oxygen, Ubuntu, Cantarell, &quot;Open Sans&quot;, &quot;Helvetica Neue&quot;, sans-serif; font-size: 15px; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal;">共享变量修改,多个闭包修改到同一个变量</span></div></li></ul><li><div><span style="color: rgb(15, 17, 21); font-family: quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, Oxygen, Ubuntu, Cantarell, &quot;Open Sans&quot;, &quot;Helvetica Neue&quot;, sans-serif; font-size: 16px; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: pre-wrap; background-color: rgb(237, 243, 254);">在lambda表达式中使用局部变量,成员变量,静态变量;三者是否都会产生闭包?</span></div></li><ul><li><div><span style="font-size: 12pt; color: rgb(15, 17, 21); font-family: quote-cjk-patch;">局部变量--会产生闭包,因为变量脱离其作用域但是与上下文产生联系</span></div></li><li><div><span style="font-size: 12pt; color: rgb(15, 17, 21); font-family: quote-cjk-patch;">静态变量 --不会产生闭包,</span> <span style="color: rgb(15, 17, 21); font-family: quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, Oxygen, Ubuntu, Cantarell, &quot;Open Sans&quot;, &quot;Helvetica Neue&quot;, sans-serif; font-size: 16px; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal;">它的生命周期与应用程序域（AppDomain）相同</span></div></li><li><div><span style="font-size: 12pt; color: rgb(15, 17, 21); font-family: quote-cjk-patch;">成员变量 --会产生this捕获,不是传统意义上的闭包</span></div></li></ul></ul><li><div>await task后的线程是主线程吗? <span style="color: rgb(15, 17, 21); font-family: quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, Oxygen, Ubuntu, Cantarell, &quot;Open Sans&quot;, &quot;Helvetica Neue&quot;, sans-serif; font-size: 16px; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal;">取决于执行环境的同步上下文（SynchronizationContext）</span></div></li><ul><li><div><span style="color: rgb(15, 17, 21); font-family: quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, Oxygen, Ubuntu, Cantarell, &quot;Open Sans&quot;, &quot;Helvetica Neue&quot;, sans-serif; font-size: 16px; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal;">Windows Forms: 在UI线程中使用await会返回原始线程,通过 上下文同步 自动底层实现的</span></div></li><li><div>使用 <span style="box-sizing: border-box; font-variant: normal; font-stretch: 100%; line-height: 22px; font-optical-sizing: auto; font-size-adjust: none; font-kerning: auto; font-feature-settings: normal; font-variation-settings: normal; font-family: Menlo, Monaco, &quot;Cascadia Mono&quot;, Consolas, &quot;Ubuntu Mono&quot;, &quot;DejaVu Sans Mono&quot;, &quot;Liberation Mono&quot;, &quot;JetBrains Mono&quot;, &quot;Fira Code&quot;, Cousine, &quot;Roboto Mono&quot;, &quot;Courier New&quot;, Courier, sans-serif, system-ui; background-color: rgb(235, 238, 242); border-radius: 6px; display: inline-flex; font-size: 0.875em !important;">ConfigureAwait(false)</span> 会避免回到原始上下文</div></li><li><div><span style="font-weight: bold; color: rgb(15, 17, 21); font-family: quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, Oxygen, Ubuntu, Cantarell, &quot;Open Sans&quot;, &quot;Helvetica Neue&quot;, sans-serif; font-size: 16px; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal;">线程池中的 await:</span>在线程池上下文中，<span style="box-sizing: border-box; font-variant: normal; font-stretch: 100%; line-height: 22px; font-optical-sizing: auto; font-size-adjust: none; font-kerning: auto; font-feature-settings: normal; font-variation-settings: normal; font-family: Menlo, Monaco, &quot;Cascadia Mono&quot;, Consolas, &quot;Ubuntu Mono&quot;, &quot;DejaVu Sans Mono&quot;, &quot;Liberation Mono&quot;, &quot;JetBrains Mono&quot;, &quot;Fira Code&quot;, Cousine, &quot;Roboto Mono&quot;, &quot;Courier New&quot;, Courier, sans-serif, system-ui; background-color: rgb(235, 238, 242); border-radius: 6px; display: inline-flex; font-size: 0.875em !important;">await</span> 后可能在任何线程池线程上继续执行</div></li><li><div><b><span style="color: rgb(15, 17, 21); font-family: quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, Oxygen, Ubuntu, Cantarell, &quot;Open Sans&quot;, &quot;Helvetica Neue&quot;, sans-serif; font-size: 16px; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal;">在 Unity 中，</span><span style="box-sizing: border-box; font-variant: normal; font-stretch: 100%; line-height: 22px; font-optical-sizing: auto; font-size-adjust: none; font-kerning: auto; font-feature-settings: normal; font-variation-settings: normal; font-family: Menlo, Monaco, &quot;Cascadia Mono&quot;, Consolas, &quot;Ubuntu Mono&quot;, &quot;DejaVu Sans Mono&quot;, &quot;Liberation Mono&quot;, &quot;JetBrains Mono&quot;, &quot;Fira Code&quot;, Cousine, &quot;Roboto Mono&quot;, &quot;Courier New&quot;, Courier, sans-serif, system-ui; background-color: rgb(235, 238, 242); border-radius: 6px; display: inline-flex; font-size: 0.875em !important; color: rgb(15, 17, 21); letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal;">await Task.Run</span><span style="color: rgb(15, 17, 21); font-family: quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, Oxygen, Ubuntu, Cantarell, &quot;Open Sans&quot;, &quot;Helvetica Neue&quot;, sans-serif; font-size: 16px; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255);"> </span></b><span style="color: rgb(15, 17, 21); font-family: quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, Oxygen, Ubuntu, Cantarell, &quot;Open Sans&quot;, &quot;Helvetica Neue&quot;, sans-serif; font-size: 16px; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal;"><b>之后，代码会回到主线程（Unity 线程）</b>，</span> <span style="box-sizing: border-box; font-variant: normal; font-stretch: 100%; line-height: 22px; font-optical-sizing: auto; font-size-adjust: none; font-kerning: auto; font-feature-settings: normal; font-variation-settings: normal; font-family: Menlo, Monaco, &quot;Cascadia Mono&quot;, Consolas, &quot;Ubuntu Mono&quot;, &quot;DejaVu Sans Mono&quot;, &quot;Liberation Mono&quot;, &quot;JetBrains Mono&quot;, &quot;Fira Code&quot;, Cousine, &quot;Roboto Mono&quot;, &quot;Courier New&quot;, Courier, sans-serif, system-ui; background-color: rgb(235, 238, 242); border-radius: 6px; display: inline-flex; font-size: 0.875em !important; color: rgb(15, 17, 21); letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal;">UnitySynchronizationContext</span><span style="color: rgb(15, 17, 21); font-family: quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, Oxygen, Ubuntu, Cantarell, &quot;Open Sans&quot;, &quot;Helvetica Neue&quot;, sans-serif; font-size: 16px; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255);"> </span><span style="color: rgb(15, 17, 21); font-family: quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, Oxygen, Ubuntu, Cantarell, &quot;Open Sans&quot;, &quot;Helvetica Neue&quot;, sans-serif; font-size: 16px; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal;">会自动将延续（continuation）派发回主线程执行</span></div></li></ul><li><div>图形渲染中阴影是怎么实现的</div></li></ul></div><div><br/></div></span>
</div></body></html> 